开发者

Bash-script printing a pdf to a pdf in Linux

开发者 https://www.devze.com 2022-12-11 18:13 出处:网络
The question probably sounds a little odd, but the actual task is relatively simple, I swear! I\'m automatically generating some PDFs from a webform, using PDFCreator to merge a generated FDF into a

The question probably sounds a little odd, but the actual task is relatively simple, I swear!

I'm automatically generating some PDFs from a webform, using PDFCreator to merge a generated FDF into a preexisting PDF. I created the preexisting PDF in NitroPDF. This setup works great - almost. The problem is that when you view the generated PDFs in Adobe Reader 9 (the most common reader) a subset of the fields are just blank. The information is still there; using previous versions of Adobe Reader or a different reader like Foxit Reader shows the entire PDF. No clue what's going on, and Adobe tech support was useless since I didn't create the PDF with Adobe software. (If you'd like to help fix this problem instead of the following, feel free to email me.)

However, if I take the resultant PDF and print it to a fresh PDF using a PDF printer driver, it works great everywhere. This is time-consuming and annoying for our sales department to do themselves, so I want to perform this step automagically upon creating the first PDF.

I'm in ubuntu, and have command-line root access to the server. Th开发者_Go百科e program is written in PHP, and can easily make system calls. I'm just having trouble figuring out how to tie things together properly so that I can automatically print a known file using a specific printer driver to another known file.


You could try putting your PDF files through Ghostscript. I have found that this is enough to fix many problematic PDFs.

gs -q -dNOPAUSE -dBATCH -sDEVICE=pdfwrite -sOutputFile=output.pdf input.pdf

(The same command can also be used to merge several PDF files into one, just specify multiple input files.)

0

精彩评论

暂无评论...
验证码 换一张
取 消