pdftk

PDF 的命令行操作

爷,独闯天下 提交于 2019-11-29 09:38:17
pdftk 命令 提供了许多处理 PDF 的 命令 行操作,包括合并页面、加密文件、添加水印、压缩文件,甚至还有修复 PDF。 虽然 PDF 通常被认为是相当稳定的文件,但在 Linux 和其他系统上你可以做很多处理。包括合并、拆分、旋转、拆分成单页、加密和解密、添加水印、压缩和解压缩,甚至还有修复。 pdftk 命令能执行所有甚至更多操作。 “pdftk” 代表 “PDF 工具包”(PDF tool kit),这个命令非常易于使用,并且可以很好地操作 PDF。例如,要将独立的文件合并成一个文件,你可以使用以下命令: $ pdftk pg1.pdf pg2.pdf pg3.pdf pg4.pdf pg5.pdf cat output OneDoc.pdf OneDoc.pdf 将包含上面显示的所有五个文档,命令将在几秒钟内运行完毕。请注意,cat 选项表示将文件连接在一起,output 选项指定新文件的名称。 你还可以从 PDF 中提取选定页面来创建单独的 PDF 文件。例如,如果要创建仅包含上面创建的文档的第 1、2、3 和 5 页的新 PDF,那么可以执行以下操作: $ pdftk OneDoc.pdf cat 1-3 5 output 4pgs.pdf 另外,如果你想要第 1、3、4 和 5 页(总计 5 页),我们可以使用以下命令: $ pdftk OneDoc.pdf

How do I install Pdftk on my server?

吃可爱长大的小学妹 提交于 2019-11-29 09:24:23
问题 I am using a Linux Server and am trying to install Pdftk, but I am problems trying to figure out what exactly to do. I found the following documentation on how to install it, but they refer mostly to installing it on the local Windows machine. They are: http://www.andrewheiss.com/blog/2009/07/29/installing-pdftk-php/ http://www.accesspdf.com/pdftk/#packages Can someone help me unserstand exactly what files I need to place where on my server so I can refer to pdftk? 回答1: Pdftk is a version of

Adding metadata to PDF via PHP

[亡魂溺海] 提交于 2019-11-29 07:38:49
I need to augment a PDF with a custom metadata field on download in PHP (5.3). I have been looking at the pdftk library, but I can't get my head around how I would get PHP to interface with it on our (Ubuntu) web server. The deprecated PDFInfo library seems like a dead end. Is there a simpler/easier/better solution? Thanks Gordon You could use Zend_Pdf . It's from the Zend Framework but can be used as a standalone component. Adding metadata is as easy as: $pdf = Zend_Pdf::load($pdfPath); $pdf->properties['Title'] = 'New Title.'; $pdf->save($pdfPath); 来源: https://stackoverflow.com/questions

Split a PDF in two

自作多情 提交于 2019-11-28 16:57:11
问题 How do you easily split a large PDF into two (or more) separate PDFs? Say we have foo-bar.pdf, section foo is from page 1-12 and section bar is from page 13 till the end. I want foo-bar.pdf split into foo.pdf and bar.pdf. 回答1: You can use pdftk, it's a handy tool for manipulating PDF documents. sudo apt-get --yes install pdftk pdftk foo-bar.pdf cat 1-12 output foo.pdf pdftk foo-bar.pdf cat 13-end output bar.pdf You can use this method to split a PDF in N ways, or to remove pages. For example,

Flatten FDF / XFDF forms to PDF in PHP with utf-8 characters

老子叫甜甜 提交于 2019-11-28 10:59:06
My scenario: A PDF template with formfields: template.pdf An XFDF file that contains the data to be filled in: fieldData.xfdf Now I need to have these to files combined & flattened. pdftk does the job easily within php: exec("pdftk template.pdf fill_form fieldData.xfdf output flatFile.pdf flatten"); Unfortunately this does not work with full utf-8 support. For example: Cyrillic and greek letters get scrambled. I used Arial for this, with an unicode character set. How can I accomplish to flatten my unicode files? Is there any other pdf tool that offers unicode support? Does pdftk have an

Keep a pdf form editable after filling it with pdftk

瘦欲@ 提交于 2019-11-28 09:01:55
问题 I'm using pdftk to fill a form but the output form isn't editable, when I open it on acrobat reader I'm getting an error message: "This document enabled extended features in Adobe Reader, The document has been changes since it was created and use of extended features is no longer available." is it possible to keep the document editable? 回答1: No. AFAIK for a PDF to be editable in Adobe Reader it has to be digitally signed by Adobe Acrobat. Obviously manipulating a PDF with pdftk changes the

How to repair a PDF file and embed missing fonts

吃可爱长大的小学妹 提交于 2019-11-28 08:27:28
I use pdftk to repair some failures in corrupted PDF files, but I faced another problem which is not fixed by pdftk (or at least I do not know how to do so). I have PDF files with text based on TrueType fonts, but the fonts have not been embedded during PDF creation. Now I want to embed the required fonts to the existing files. Is there a command-line tool (like pdftk ) to embed missing fonts by providing path to TTF files? Kurt Pfeifle You can use Ghostscript to embed missing fonts. Run the command like this: gs \ -o file-with-embedded-fonts.pdf \ -sDEVICE=pdfwrite \ -dEmbedAllFonts=true \

PDFtk hanging on MacOS Sierra

别来无恙 提交于 2019-11-28 03:17:38
PDFtk Server seems to be hanging indefinitely on MacOS Sierra. Looks similar to the problem it had on El Capitan . I'm trying to run this command: pdftk test1.pdf test2.pdf cat output out.pdf verbose And am getting no output, just an indefinite hang. Same with every other command I've tried. PDFtk --version: pdftk 2.02 a Handy Tool for Manipulating PDF Documents Copyright (c) 2003-13 Steward and Lee, LLC - Please Visit: www.pdftk.com This is free software; see the source code for copying conditions. There is NO warranty, not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. Has

Merge PDF's with PDFTK with Bookmarks?

非 Y 不嫁゛ 提交于 2019-11-28 03:09:09
Using pdftk to merge multiple pdf's is working well. However, any easy way to make a bookmark for each pdf merged? I don't see anything on the pdftk docs regarding this so I don't think it's possible with pdftk. All of our files merged will be 1 page, so wondering if there's any other utility that can add in bookmarks afterwards? Or another linux based pdf utility that will allow to merge while specifying a bookmark for each individual pdf. Kurt Pfeifle You can also merge multiple PDFs with Ghostscript. The big advantage of this route is that a solution is easily scriptable, and it does not

Adding metadata to PDF via PHP

一曲冷凌霜 提交于 2019-11-28 01:34:50
问题 I need to augment a PDF with a custom metadata field on download in PHP (5.3). I have been looking at the pdftk library, but I can't get my head around how I would get PHP to interface with it on our (Ubuntu) web server. The deprecated PDFInfo library seems like a dead end. Is there a simpler/easier/better solution? Thanks 回答1: You could use Zend_Pdf. It's from the Zend Framework but can be used as a standalone component. Adding metadata is as easy as: $pdf = Zend_Pdf::load($pdfPath); $pdf-