I'm writing an application that faxes a document (many supported types) provided by the end user. A requirement is that the end user can also provide text to be used as part of a custom fax header.
I've been using Ghostscript to render PDFs as TIFFs and it's been working great so far, but I have yet to find a straightforward way of overlaying the custom header at the top of a PDF. I've tried out a few recommendations:
... with no luck.
I've used ImageMagick to do this successfully with documents rendered to TIFF via other tools, and I'm aware that ImageMagick can render PDF-to-TIFF on its own. However, I want to stick with Ghostscript because in my experience it has performed better and rendered clearer TIFFs.
Is this possible using Ghostscript and perhaps a PS helper script?
Edit:
Ghostscript (v9.04) is not throwing any errors. For example:
gswin64c -dSAFER -dBATCH -dNOPAUSE -dPDFFitPage -sDEVICE=tiffg3 ^
-sOutputFile=goofy.tif ^
-c "/Courier findfont 12 scalefont setfont 50 765 moveto (header text) show" ^
-f goofy.pdf
... produces a TIFF of the original PDF, but without the text I tried to add. If I append showpage
to the postscript one-liner it (predictably, I suppose) prints a new, blank-except-for-header page, which doesn't help me much.
I would use another commandline tool combined with Ghostscript for this task. This tool is pdftk.exe
. Then use a 3 step approach:
gswin64c.exe ^ -o header.pdf ^ -sDEVICE=pdfwrite ^ -c "/Courier findfont 12 scalefont setfont" ^ -c "50 765 moveto (header text) show showpage"
pdftk.exe goofy.pdf background header.pdf output goofy-with-header.pdfor
pdftk.exe goofy.pdf stamp header.pdf output goofy-with-header.pdf
gswin64c.exe ^ -dPDFFitPage ^ -o goofy-with-header.tif ^ -sDEVICE=tiffg3 ^ goofy-with-header.pdf
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With