Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Take a look at a program called <a href="http://bitbucket.org/codepoet/cups-pdf-for-mac-os-x/wiki/Home" rel="nofollow">CUPS-PDF</a> </p> <p>It is a virtual printer for OS X which does what the "Save As PDF" method does when print through your normal printer except every print job passed through it results in a pdf output.</p> <p>Once you install it then you could create shell or AppleScripts using the <strong>lp</strong> command. </p> <p>For example, once the virtual printer is setup you could print test.txt and have it automatically save as a pdf. To do this using an AppleScript you would use the following code:</p> <pre><code>do shell script "lp -d CUPS_PDF test.txt" </code></pre> <p>The CUPS-PDF app saves all output to /Users/Shared/CUPS-PDF. I am not sure if you can change that path but you could retrieve the file in your script and move it.</p> <p>There are a few caveats though. </p> <p>First, the <strong>lp</strong> command cannot print .doc files. I think there are some other third party apps which will allow you to do this though. </p> <p>Second, the CUPS-PDF app shows in the Printer pane of System Preferences as having the hyphen in its name but CUPS shows the queue name as having an underscore. So, on the command line you need to refer to the CUPS queue name which is CUPS_PDF with an underscore.</p> <p>Even if you don't find it very useful to build a script via the <strong>lp</strong> command and still want to involve GUI scripting then having a virtual printer should save you some steps.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload