How to find and replace text in a existing PDF file with PDFTK (or other command line application) [closed]

You can try to modify content of your PDF as follows Uncompress the text streams of PDF pdftk file.pdf output uncompressed.pdf uncompress Use sed to replace your text with another sed -e “s/ORIGINALSTRING/NEWSTRING/g” <uncompressed.pdf >modified.pdf If this attempt was successful, re-compress the PDF with pdftk pdftk modified.pdf output recompressed.pdf compress Note: This way is not … Read more

Merge PDF’s with PDFTK with Bookmarks?

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 require a real programming effort: gswin32c.exe ^ -dBATCH -dNOPAUSE ^ -sDEVICE=pdfwrite ^ -sOutputFile=merged.pdf ^ […more Ghostscript options as needed…] ^ input1.pdf input2.pdf input3.pdf [….] With Ghostscript you’ll be able to … Read more

PDFTK Rotating Pages Problem

To rotate page 1 by 90 degrees clockwise: pdftk in.pdf cat 1E output out.pdf # old pdftk pdftk in.pdf cat 1east output out.pdf # new pdftk To rotate all pages clockwise: pdftk in.pdf cat 1-endE output out.pdf # old pdftk pdftk in.pdf cat 1-endeast output out.pdf # new pdftk Similarly, to rotate all pages anti-clockwise: … Read more

Remove the last page of a pdf file using PDFtk?

This will create the outfile.pdf with all but the last page in infile.pdf pdftk infile.pdf cat 1-r2 output outfile.pdf Explanation of parameters infile.pdf is the original pdf file cat is the operation 1-r2 is the page range You can reference page numbers in reverse order by prefixing them with the letter r. For example, page … Read more

Split a PDF in two

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, to remove page 13: pdftk in.pdf cat 1-12 … Read more

PDFtk hanging on MacOS Sierra

Use this version: https://www.pdflabs.com/tools/pdftk-the-pdf-toolkit/pdftk_server-2.02-mac_osx-10.11-setup.pkg Although it’s prepared for El Capitan (10.11), it also works on Big Sur (11), Catalina (10.15), Mojave (10.14), High Sierra (10.13), and Sierra (10.12).

pdftk compression option

I had the same problem and found two different solutions (see this thread for more details). Both reduced the size of my uncompressed PDF dramatically. Pixelated (lossy): convert input.pdf -compress Zip output.pdf Unpixelated (lossless, but may display slightly differently): gs -sDEVICE=pdfwrite -dCompatibilityLevel=1.4 -dPDFSETTINGS=/screen -dNOPAUSE -dBATCH -dQUIET -sOutputFile=output.pdf input.pdf Edit: I just discovered another option (for … Read more

tech