Cups pdf mac os

Cups pdf mac os

Martin-Éric Racine maintains a Debian package of CUPS-PDF which is part of the official distribution.

For openSUSE packages are maintained at their Build Service.

Remi Collet maintains RPM packages for Fedora, RHEL, and CentOS which are available from Fedora packages.

For Gentoo there is a package of CUPS-PDF in the net-print category.

A build of CUPS-PDF for Slackware can be found on SlackBuilds.org.

On bitbucket a package for Mac OS X is available. Futhermore, MacPorts offers a portfile.

Simon Olofsson maintains a port of the current CUPS-PDF for FreeBSD on FreshPorts.

CUPS-PDF is also available in the packages and ports collection of OpenBSD.

A package of CUPS-PDF for the T2 System Development Environment can be found here.

User-contributed addons for CUPS-PDF

pstitleiconv by Nickolay Kondrashov (c) 2006:

  • This filter allows conversion of character encoding in PS files for processing by CUPS-PDF. This will allow international characters in filenames when printing from Windows clients.

cups-pdf-dispatch by Nickolay Kondrashov (c) 2006:

  • An elaborate postprocessing script for CUPS-PDF that allows sending mails with the created PDFs to users.

config2lpoptions by Louis Lagendijk (c) 2011:

  • This script uses a CUPS-PDF config file and converts its contents to lpoption settings for the current user (take care: executing it as root will set the system default!).

As far as not explicitly stated otherwise all of the contributed software is distributed under the same license as CUPS-PDF (GPLv2) — check Licensing for more information.

Источник

Programming a Filter/Backend to ‘Print to PDF’ with CUPS from any Mac OS X application

Okay so here is what I want to do. I want to add a print option that prints whatever the user’s document is to a PDF and adds some headers before sending it off to a device.

I guess my questions are: how do I add a virtual «printer» driver for the user that will launch the application I’ve been developing that will make the PDF (or make the PDF and launch my application with references to the newly generated PDF)? How do I interface with CUPS to generate the PDF? I’m not sure I’m being clear, so let me know if more information would be helpful.

I’ve worked through this printing with CUPS tutorial and seem to get everything set up okay, but the file never seems to appear in the appropriate temporary location. And if anyone is looking for a user-end PDF-printer, this cups-pdf-for-mac-os-x is one that works through the installer, however I have the same issue of no file appearing in the indicated directory when I download the source and follow the instructions in the readme. If anyone can get either of these to work on a mac through the terminal, please let me know step-by-step how you did it.

2 Answers 2

The way to go is this:

Set up a print queue with any driver you like. But I recommend to use a PostScript driver/PPD. (A PostScript PPD is one which does not contain any *cupsFilter: . line.):

Initially, use the (educational) CUPS backend named 2dir . That one can be copied from this website: KDE Printing Developer Tools Wiki. Make sure when copying that you get the line endings right (Unix-like).

Commandline to set up the initial queue: The 2dir backend now will write all output to directory /tmp/pdfqueue/ and it will use a uniq name for each job. Each result should for now be a PostScript file. (with none of the modifications you want yet).

Locate the PPD used by this queue in /etc/cups/ppd/ (its name should be pdfqueue.ppd ).

Add the following line (best, near the top of the PPD): (Make sure the *cupsFilter starts at the very beginning of the line.) This line tells cupsd to auto-setup a filtering chain that produces PDF and then call the last filter named ‘-‘ before it sends the file via a backend to a printer. That ‘-‘ filter is a special one: it does nothing, it is a passthrough filter.

Re-start the CUPS scheduler:

From now on your pdfqueue will cause each job printed to it to end up as PDF in /tmp/pdfqueue/*.pdf .

Study the 2dir backend script. It’s simple Bash, and reasonably well commented.

Modify the 2dir in a way that adds your desired modifications to your PDF before saving on the result in /tmp/pdfqueue/*.pdf .

Update: Looks like I forgot 2 quotes in my originally prescribed *cupsFilter: . line above. Sorry!

I really wish I could accept two answers because I don’t think I could have done this without all of @Kurt Pfeifle ‘s help for Mac specifics and just understanding printer drivers and locations of files. But here’s what I did:

Download the source code from codepoet cups-pdf-for-mac-os-x. (For non-macs, you can look at http://www.cups-pdf.de/) The readme is greatly detailed and if you read all of the instructions carefully, it will work, however I had a little trouble getting all the pieces, so I will outline exactly what I did in the hopes of saving someone else some trouble. For this, the directory with the source code is called «cups-pdfdownloaddir».

Compile cups-pdf.c contained in the src folder as the readme specifies:

gcc -09 -s -lcups -o cups-pdf cups-pdf.c

There may be a warning: ld: warning: option -s is obsolete and being ignored , but this posed no issue for me. Copy the binary into /usr/libexec/cups/backend. You will likely have to the sudo command, which will prompt you for your password. For example:

sudo cp /cups-pdfdownloaddir/src/cups-pdf /usr/libexec/cups/backend

Also, don’t forget to change the permissions on this file—it needs root permissions (700) which can be changed with the following after moving cupd-pdf into the backend directory:

sudo chmod 700 /usr/libexec/cups/backend/cups-pdf

Edit the file contained in /cups-pdfdownloaddir/extra/cups-pdf.conf. Under the «PDF Conversion Settings» header, find a line under the GhostScript that reads #GhostScript /usr/bin/gs . I did not uncomment it in case I needed it, but simply added beneath it the line Ghostscript /usr/bin/pstopdf . (There should be no pre-cursor # for any of these modifications)

Find the line under GSCall that reads #GSCall %s -q -dCompatibilityLevel=%s -dNOPAUSE -dBATCH -dSAFER -sDEVICE=pdfwrite -sOutputFile=»%s» -dAutoRotatePage\ s=/PageByPage -dAutoFilterColorImages=false -dColorImageFilter=/FlateEncode -dPDFSETTINGS=/prepress -c .setpdfwrite \ -f %s Again without uncommenting this, under this I added the line GSCall %s %s -o %s %s

Читайте также:  Драйвер x64 hp scanjet 2400 для windows

Find the line under PDFVer that reads #PDFVer 1.4 and change it to PDFVer , no spaces or following characters.

Now save and exit editing before copying this file to /etc/cups with the following command

sudo cp cups-pdfdownloaddir/extra/cups-pdf.conf /etc/cups

Be careful of editing in a text editor because newlines in UNIX and Mac environments are different and can potentially ruin scripts. You can always use a perl command to remove them, but I’m paranoid and prefer not to deal with it in the first place.

You should now be able to open a program (e.g. Word, Excel, . ) and select File >> Print and find an available printer called CUPS-PDF. Print to this printer, and you should find your pdfs in /var/spool/cups-pdf/yourusername/ by default.

*Also, I figured this might be helpful because it helped me: if something gets screwed up in following these directions and you need to start over/get rid of it, in order to remove the driver you need to (1) remove the cups-pdf backend from /usr/libexec/cups/backend (2) remove the cups-pdf.conf from /etc/cups/ (3) Go into System Preferences >> Print & Fax and delete the CUPS-PDF printer.

This is how I successfully set up a pdf backend/filter for myself, however there are more details, and other information on customization contained in the readme file. Hope this helps someone else!

Источник

Cups pdf mac os

The macosxhints Rating:

[Score: 10 out of 10]

  • Developer: codepoetry/ Product page
  • Price: Free

CUPS-PDF is a free little package that was mentioned back in March in this hint as part of a solution to batch converting Word documents to PDF. However, CUPS-PDF is actually an amazingly useful little add-on for nearly anyone who regularly prints to PDF. CUPS-PDF installs a «virtual» PDF printer, which you can then select and use just as you would a normal printer. When you print a job to the virtual PDF printer, the output shows up in a cups-pdf folder on your desktop.

Yes, you can do exactly the same thing by clicking the PDF button in the Print dialog, then selecting Save as PDF from the drop-down menu. But CUPS-PDF makes the process much faster and easier. With the built-in solution, you have to not only click a button and choose a menu item, you then have to pick a name and save location for the resulting file. CUPS-PDF print jobs are always named after the document that you printed (prefixed by a job number), and they’re automatically saved to the cups-pdf folder on your desktop. So if you set the virtual PDF printer as your default, you can print to a PDF by just pressing Command-P then Return. This makes it a snap to convert a number of existing documents, or to easily save all your web receipts during an extensive online shopping trip.

Another way to use your virtual printer is to make a desktop printer out of it (in Printer Setup Utility). Store it in your dock for fast access, and then just drag and drop print jobs to it when you need something turned into a PDF. And yes, Adobe Acrobat Pro includes a virtual PDF writer . but this solution is completely free, works very well, and integrates perfectly into the Print dialog. Well worth a look if you’re a heavy user of PDF printing.

  • Currently 2.96 / 5

You rated: 3 / 5 (24 votes cast)

Hint Options

I have never got this to work.
I think the reason is found at
http://www.codepoetry.net/support/other_software/cups_pdf_package/cannot_install_cups_pdf_printer
where it says:
===========
This is for the stock version of CUPS that comes with Mac OS X. If you’ve installed a different version then you need to manually install the backend module at /usr/libexec/cups/backend/cups-pdf into the proper directory for your version of CUPS.
=============
I have installed CUPS 1.2.12 and am using OS X 10.4.10.

I do not know where to go with this instruction «to manually install…» to try to get it to work.

I have actually gotten it to work — and the hint a while back was more specific than this repost. Anyway, in the end it seemed kinda pointless given OS X’s native print to PDF capabilities. Adding additional Automator workflows helps the print-to-pdf functionality as well.

The only use I found for the CUPS-PDF was to *share* the ability to print to PDF to those less fortunate Windows users. While this worked for most general purpose documents, it seemed to fall down pretty hard on (you guessed it) various PowerPoint type files (images, specifically).

I am not surprised. I never understood the purpose of amateur software like CUPS which apparently is only useful for exotic or outdated printer models?

I neither understand why on a Mac(!) the 1560. PDF Utility shall be a 10 point pick of the week?

I neither understand why this part of the osxhint webpage is barely readable with Safari as there are no line breaks.

Some special applications need special tools.
E.g. the virtual machine of Parallels Desktop. I do not want to miss or I cannot miss some WIN programs. So I use the virtual machine of Parallels.
To avoid printing output on paper I tested some other PDF tools as FreePDF and DoPDF-7. But I was not able to change these printers to standard printers. I have to use a virtual PDF printer and set to standard on the Mac side. So I was happy to find a driver as CUPS-PDF.

Another way this could be done would be to create a customer Automator Workflow and save it in /Library/PDF Services/

Use the «Save PDF to Web Receipts Folder» as a template. Can also add timestamping and other information.

The difference with a dedicated PDF Printer is, that it can be used non-interactively from any script and without any GUI needed. This can be very handy if you want to automate workflows or processes that do not involve a user to click buttons.
I’d like to see a CUPS receipt that will allow me to automatically sign a PDF I print through it with a cryptographic signature. I haven’t yet found any automated solution to do this on the Mac. Pepi

Читайте также:  Восстановление windows alt f10

Except that Save as PDF won’t work in Adobe Reader 8 — Adobe blocked this. Why would I want to save a PDF to PDF?

Form PDFs don’t allow saving, so the helpful note from Adobe when you open one says to print a copy after filling in the form if you want a record of what you filled in. But you can’t save to PDF when printing from Reader 8, so the only way to get a digital copy of the filled-in form is to print thru a virtual printer.

This sounds promising, as I have to convert a bunch of keynote presentations to pdfs for students to download after my lectures (kids these days — want everything handed to them!). Keynote’s (Apple’s) built in export to PDF / print to PDF options both lead to rather large files that are tough on dialup lines. So my question is — does this make the pdf files smaller than Apple’s version? I guess I’ll get around to testing this one of these days but if anyone knows the answer, I’d appreciate hearing about it.

I printed the macosxhints webpage. With save as «pdf» it’s 352 kb, with the CUPS-PDF 2.8 MB

Similar results here. On a 2-page document (with graphics) in Pages:

CUPS-PDF: 6 MB
Print-to-PDF: 184 KB

I found the resulting PDF files to be very large, much larger than save as «compress PDF» or even as PDF

Have you got any more info about the large size of the pdf documents created by cups-pdf?

How does this do the paging of the resultant PDF?

I use Paparazzi for printing PDFs just because it automatically makes the resultant PDF one large/long file. Very handy when printing web apges and you don’t want embedded images or whatever split between pages.

If this did the same thing I could dump Paparazzi becuase it is kinda tedious to have to re-open the URL in the program and then save.

I just joined and was reading this particular thread and will continue to explore to find other things. However, this is what I need to know (or learn is maybe a better word).

Yesterday I just discovered that I could create a PDF using Illustrator. I tested it, send my 1st PDF file in an email to test it. all is A-OK. Now I get eager for more PDF knowledge. but I am an old feeble minded person who kind of needs ‘ABC directions’ to do things. I am also a financially broke old person, so going out and purchasing software that will DO what I want is out of the question right now.

My Goal is to create a multiple page PDF and preferably with clickable links. though active hyperlinks is on the bottom of my list right now. I see many talking about PDFs here, and tips/tricks to do. but frankly my mind is boggled. Can anyone help me out with an EZ to use/follow system?

Does anyone know how to change the name of the cups-pdf Folder?

### Key: Out
## CUPS-PDF output directory
## special qualifiers:
## $ will be expanded to the user’s home directory
## $ will be expanded to the user name
## in case it is an NFS export make sure it is exported without
## root_squash!
### Default: /var/spool/cups-pdf/$

I was able to use this hint to print a PDF copy of a document which was protected by Adobe’s LiveCycle Rights Management. The trick is to select «Print as image» in the Advanced Print Setup dialog (accessible from the Advanced button in Reader’s print dialog). This creates a huge file (63MB in my case), but it does work. The resulting PDF can be opened in Preview.app, which was not the case with my original document. Opening this document and printing it to a PDF from Preview (via the PDF menu in the print dialog) will create a much smaller file.

Of course, this method turns the document into a bitmap, so you don’t get selectable, scalable text, but it does allow you to save a local copy of a protected document.

Overall Problem(s): The current (v2.4.6.1) CodePoetry package of CUPS-PDF driver doesn’t work under Snow Leopard. After installing the package, the CUPS-PRINTER doesn’t even show up in the Printer & Fax system prefs when you select ‘Add Printer’.

Solution step#1: Per the latest CUPS-PDF README, the /usr/libexec/cups/backend/cups-pdf binary must now be chmod’ed 0700 and be chowned by root:wheel. Otherwise, the CUPS-PRINTER won’t even show up. Do this and the CUPS-PRINTER should now appear and allow you to add it.

Solution step#2: The new ‘application sandbox’ feature in 10.6 won’t allow the required pstopdf binary to write to a folder in a user’s homedir. So the default ‘Out $/Desktop/cups-pdf/’ entry in the /etc/cups/cups-pdf.conf file will cause the printjob to silently fail. (Watch System.log for evidence of this)

After wasting a few hours trying different methods to get the sandbox to create an exception for pstopdf, I gave up. Instead I just edited the cups-pdf.conf entry to point to somewhere the sandbox will allow (e.g. ‘/var/spool/cups-pdf/$‘ ) then just symlinked it to a folder in my homedir.

At the moment I prefer this rather than potentially messing with the system-wide sandbox config, since this security mechanism isn’t completely documented as of yet.

NOTE: While I applaud the CodePoetry author for creating the prepackaged OSX installer, if anyone reading this is going to actually dig this deep to get it to work under Snow Leopard, you might consider just building the original CUPS-PDF driver (it’s only a single file) directly from the source. See http://www.cups-pdf.de . The current latest (v2.5.0) worked fine for me using the above techniques. Just don’t forget that you need to manually install/edit the cups-pdf.conf file also.

Hmmm, can’t get this working under SL — the CUPS printer is created, but when printing it just appears in the dock for a bounce or two but then is gone.

Can someone provide detailed steps?

Thanks for this. The codepoetry site leads one to believe that version 2.4.6.1 addresses this issue, but I did not find that to be the case.

to get CUPS-PDF to work with Snow Leopard — 10.6.0 or .1
— referring to CUPS-PDF 2.5.0 package’s README

Permission setting for the BackEnd
via Terminal
cd /usr/libexec/cups/backend/
sudo chmod 0700 cups-pdf

Output Folder
Snow Leopard objects to $ and $
Suggestion
1. Finder —> Go —> Go to Folder ….
«/etc/cups» and punch Go
2. Select cups-pdf.conf and drag to your Desktop
3. On your Desktop, select cups-pdf.conf
4. Ctrl-Click and Open with Textedit
a. Find «#Out »
b. On new line «Out /Users/Shared/Cups_PDF»
c. Delete any other line starting with «Out »
d. Find «#AnonDirName »
e. On new line «AnonDirName /Users/Shared/Cups_PDF/Anonymous»
f. Delete any other line starting with «AnonD»
g. Save
5. Drag cups-pdf.conf back to folder /etc/cups and Authenticate/Replace
6. via Terminal
cd /etc/cups
sudo chown root:_lp cups-pdf.conf
exit
7. On your Desktop, trash cups-pdf.conf
8. Finder —> Go —> Go to Folder ….
«/Users/Shared/Cups_PDF»
9. Ctrl-Click and Make Alias
10. Drag the Alias to your Desktop

you are right that the distributed file has ‘Out ‘, not ‘#Out’.

I would change that line to be prefixed with ‘#’ — this shows the original setting.
Then add a new line specifying another folder — without any substitutions $<. >.

the site http://www.codepoetry.net/ was updated today 2009.09.17
stating that CUPS-PDF package would be updated for Snow Leopard

I was able to get this working for 10.6 by using different directories.

You could also have a subdirectory of /var/spool/cups-pdf to match the printer name. Of course, ensure that permissions are set appropriately for whatever directory you specify here.

This is the way to go. Apparently Snow Leopard is VERY restrictive when it comes to where it allows this printer driver to write files.

Edit /etc/cups/cups-pdf.conf and put a «#» in front of any «Out» or «AnonDirName» entry (thus commenting them out). The default cups-pdf values (pointing to /var/spool/cups-pdf) will work best here.

Create the cups-pdf printer.

Print a test job to your new printer.

Run the following command:
sudo ln -s /var/spool/cups-pdf/username /Users/username/cups-pdf
(replacing «username» with your username)

Now, you should be able to see your PDF files in the «cups-pdf» folder in your home directory.

CUPS-PDF v 2.5.0 is out and it works great in Snow Leopard. Download v 2.5 from http://freshmeat.net/projects/cupspdf/. cd /Users/username/Downloads/cups-pdf-2.5.0/src Compile cups-pdf in the /src directory of the downloaded folder using gcc -O9 -s -o cups-pdf cups-pdf.c Copy the compiled code sudo cp cups-pdf /usr/libexec/cups/backend/cups-pdf The instructions state to install to /usr/lib/cups/backend which is wrong. You need to install to /usr/libexec/cups/backend Ensure you sudo chmod 0700 /usr/libexec/cups/backend/cups-pdf Per the instructions you will need to edit cups-pdf.conf. Edit the following lines in the .conf file:

  • GhostScript /usr/bin/pstopdf
  • GSCall %s %s -o %s %s
  • PDFVer Copy the edited cups-pdf.conf file to /etc/cups . All of your PDFs will be saved to /var/spool/cups-pdf/username As mentioned above, creating a symlink to /var/spool/cups-pdf/ to my desktop worked perfectly. sudo ln -s /var/spool/cups-pdf/username /Users/username/Desktop/CUPS-PDFs I also created a desktop PDF printer by option-dragging the printer to my desktop. Now I can just drag a stack of files onto the desktop printer and they are converted to PDFs and easily accessed in a folder on my desktop.

    I could not compile the source code 🙁
    I am running Leopard with X Code version 3.1.4
    I get 169 errors and 58 warnings 🙁

    However, I did use the posting here to edit the /etc/cups/cups-pdf.conf to make it work!

    Thanks for the postings.

    These instructions did the trick, thank you so much! Creating the alias is really helpful as well.
    I finally got it to work!

    This worked perfectly, both in Snow Leopard and Leopard (PPC). BTW, you can also copy the provided CUPS-PDF PPD to its location, as described in the source Read Me: «In case you want to use the color PostScript driver that comes with CUPS-PDF go to the extra/ subdirectory and copy CUPS-PDF.ppd to your CUPS model directory (usually /usr/share/cups/model [ /Generic ] ).» This will show up as «Generic CUPS-PDF Printer» when setting up the printer in System Preferences.

    I tried to use cups-pdf under snow leopard but, after have followed the instructions above, I cannot make it work. It does not show the printer in the list.

    What is the problem ?

    Thank you in advance for your help

    You have to reboot to see the new printer

    I am having trouble with this —
    and feel like I am missing something major — when I enter this line in terminal:

    gcc -09 -s -o cups-pdf cups-pdf.c

    I get the following output:

    -bash: gcc: command not found

    Do I have to have something else installed on my computer.

    You need to install Apple’s Xcode developer tools; see, for example, here:

    Thank you thank you — I got it to work — one thing —
    This works beautifully for word .doc or .docx however I do have to click through a print window for an excel file. For a PPT file I have to not only click print in the print window but it renames it as untiltled — any ideas on how to automate the renaming of those files and simplifying the process to remove the need to hit enter in the print window.

    I downloaded CUPS-PDF earlier today to try something very specific. I’d recently purchased a PDF document that I was planning to use on my iPad. Unfortunately the PDF was locked down and could only be read using Adobe Reader X. After installing CUPS-PDF (working perfectly on Snow Leopard now, at least from my limited experience) I tried to print the DRMed PDF. The file failed to show up in the designated folder.
    The solution was to open the print dialog in Reader, click the «advanced» button, check the «Print as image» box (all other options will gray out), hit «OK» to go back to the print dialog, then «OK» again to print. Worked like a charm. The resultant file will be enormous. My 46 page document came out at 1.06GB (yes, gigabytes, it was music pdf, so lots of non-text items). Opening and re-saving in Preview shrunk it down to a more manageable 52.4MB.

    Источник

  • Оцените статью