Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!


Click here to return to the 'Automagic pdf without Classic?' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Automagic pdf without Classic?
Authored by: mrhill on Mar 09, '03 05:31:38PM

This hint is wonderful, thanks!

I am attempting to kludge it to use ps2pdf13 (a part of ghostscript), and if I can get that up, it might be goodbye to classic (which I now use for Distiller).

Anyone know if there is a way to get the file and path names of the document being printed by the calling application? That might allow the script to be put right next to the document source file.



[ Reply to This | # ]
Automagic pdf without Classic?
Authored by: Thomas Kaiser on Mar 15, '03 06:11:56AM
I added some more features (to work with distiller, PStill and even GhostScript)

    http://user s.phg-online.de/tk/MOSXS/postscriptfile.gz

A brief description of the new version:

What is it?

The main purpose of this backend is to have the ability to print into
watched folders, so that output files can be postprocessed automatically
by tools like distiller, PStill, GhostScript, whatever...

How do I use it?

To use it you simply copy it into your CUPS backend folder (on MacOS X
usually /usr/libexec/cups/backend/), ensure, that it is executable and
restart the cups daemon (eg. by sending it a SIGHUP signal to reread it's
configuration)

Ah... and you'll have to configure a bit inside the script:

$TARGET_BASEDIR --> should be set as a "base dir" for hotfolders. All
paths are relative to that
$MAX_FILENAME_LENGTH --> defines how long filenames should be. This
is useful if you want to postprocess the files by e.g. distiller running in
the "classic environment"
$DEBUG --> set to TRUE to get some debug messages
$DEBUG_LOG --> This is where the backend will write log messages to
$GROUP --> this settings affects the group ownership of the files
$GS --> Specify the path to your GhostScript executable if you want to
drive the backend in ghostscript mode (see below)

Operational details:

The behaviour of the backend depends on how it is called. If you save it
as postscriptfile, than all it advertises when you invoke the PrintCenter
(while holding down [option]) is a basic print-to-disk "device". You have
to take care, that you encode the path names you want to use correctly.

If the backend will be called as "distiller", then it will advertise all
subfolders of $TARGET_BASEDIR that meet specific criteria (an "In"
folder and a folder.joboptions file inside). If it will be called as "pstill"
then it searches for a "ProcessedPS" folder and an options file, that ends
with ".pPref".

If called as "ghostscript" then it will look for a folder called "Finished" and
an options file called gs-options.txt. In this special case, it will not only
store the resulting PDF or PS file into the watched folder but instead
invoke GhostScript with the specific settings. For a detailed description
read below.

What if I want to use the backend for more than one sort of
postprocessing mechanism? Simply create symlinks to the basic
backend, as the functionality only depends on the name:

[imac-2:/usr/libexec/cups/backend/] tk# ls -la
lrwxr-xr-x 1 root wheel 14 Mar 15 09:42 distiller -> postscriptfile
lrwxr-xr-x 1 root wheel 14 Mar 15 09:42 ghostscript -> postscriptfile
-rwxr-sr-x 1 root wheel 6958 Mar 15 11:02 postscriptfile
lrwxr-xr-x 1 root wheel 14 Mar 15 09:42 pstill -> postscriptfile

How to drive GhostScript?

As there currently doesn't exist a hotfolder scheme for GhostScript, we
simply define our own :-)

Create inside $TARGET_BASEDIR a new folder, containing a subfolder
called "Finished" and a simple textfile called gs-options.txt. In this file
you write the settings you want gs to use, eg.

-q
-dNOPAUSE
-dBATCH
-r2400
-sDEVICE=pdfwrite
-dPDFSETTINGS=/prepress
-dProcessColorModel=/DeviceCMYK
-dCompatibilityLevel=1.3

(It's strongly recommended that you always use the "-q", "-dNOPAUSE"
and "-dBATCH" options because otherwise unexpected behaviour will
occur)

For a more detailled description of the settings consult the GhostScript
documentation please.

Does this make sense at all?

Maybe ;-)

You should know, how printing in MacOS X works. Applications have
basically two ways to create output that will be postprocessed by printer
drivers:

- PostScript (as we know it from former MacOS releases)
- PDF (the "standard" way in MacOS X)

As PDF is the basic technology for the Quartz display engine, most apps
simply create printer output by using Quartz. The result is a PDF file
(a mixture between PDF 1.2 and 1.3) that can be opened directly by any
any PDF 1.3 aware viewer or renderer.

When printing through CUPS these PDF files will be converted to
PostScript when the specific printer queue has been assigned a PPD file
(as it happens always when you use the PrintCenter for adding new
printers). Search for a line with "cgpdftops" at the top of such PS files, to
be sure how it has been created.

Those applications that produce still PostScript output directly (mostly
from the desktop publishing sector), will write "pictwpstops" instead in
the "%%Creator: " comment.

As you see, normally you will convert PDFs from PDF to PostScript
(invoked by a CUPS filter) and then after leaving the spooling system
back to PDF by a postprocessing mechanism. Doesn't makes always
sense, except you're using applications that produce PostScript...

Thomas Kaiser, 2003/03/15

[ Reply to This | # ]