在Linux中打印pdf到pdf格式的base -script

时间:2021-11-25 16:21:07

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.)

我从一个webform自动生成一些PDF,使用PDFCreator将生成的FDF合并到一个预先存在的PDF中。我在亚硝基PDF中创建了现有的PDF。这个设置非常有效。问题是,当您在adobereader9(最常见的阅读器)中查看生成的PDFs时,字段的子集只是空的。信息仍然存在;使用先前版本的adobereader或Foxit Reader这样的不同阅读器,可以显示整个PDF。不知道发生了什么,Adobe技术支持是无用的,因为我没有使用Adobe软件创建PDF。(如果你想帮助解决这个问题而不是以下问题,请随时给我发邮件。)

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.

但是,如果我使用一个PDF打印机驱动程序将合成的PDF打印到一个新的PDF文件中,它在任何地方都能运行得很好。这对我们的销售部门来说非常耗时和烦人,所以我想在创建第一个PDF时自动执行这个步骤。

I'm in ubuntu, and have command-line root access to the server. The 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.

我在ubuntu中,可以使用命令行根访问服务器。该程序是用PHP编写的,可以很容易地进行系统调用。我只是搞不清楚如何正确地将文件连接在一起,以便使用特定的打印机驱动程序将已知文件自动打印到另一个已知文件。

1 个解决方案

#1


4  

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

您可以尝试将您的PDF文件通过Ghostscript。我发现这足以修复许多有问题的pdf文件。

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.)

(也可以使用相同的命令将多个PDF文件合并到一个文件中,只需指定多个输入文件。)

#1


4  

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

您可以尝试将您的PDF文件通过Ghostscript。我发现这足以修复许多有问题的pdf文件。

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.)

(也可以使用相同的命令将多个PDF文件合并到一个文件中,只需指定多个输入文件。)