Questions tagged [pdftk]

70 questions
170
votes
10 answers

Command line: How do you rotate a PDF file 90 degrees?

When I scan documents that are landscape-oriented, the output PDF files are portrait and so all the PDF viewers display the scanned documents in portrait. From the command line, how do you rotate a PDF file 90 degrees? I tried searching and found a…
Trevor Boyd Smith
  • 3,772
  • 12
  • 36
  • 44
36
votes
5 answers

Why is PDFTK saying it can't find files that are right there?

I'm trying to compile a bunch of PDFs into a single document. ls shows the files are in the directory that I'm in and they're readable (-rw-r--r--). But when I try to run pdftk 2017.pdf cat output test.pdf I get an error: Error: Unexpected Exception…
Amanda
  • 1,709
  • 2
  • 13
  • 26
34
votes
4 answers

Rotate PDF pages: 90 degrees for even pages and -90 degrees for odd pages

In a PDF file, how to rotate pages 90 degrees for even pages and -90 degrees for odd pages? With PDFtk, all I know is to rotate a single page: pdftk in.pdf cat 1W output out.pdf And rotate all pages: pdftk in.pdf cat 1-endW output out.pdf
Tim
  • 98,580
  • 191
  • 570
  • 977
33
votes
9 answers

Add and edit bookmarks to a PDF file

By getting metadata from some pdf files with bookmarks by pdftk, I observe the format of bookmarks in pdf metadata. So I am guessing that with pdftk, it is possible to add and edit bookmarks of a pdf file. Here are three steps that I follow: I…
Tim
  • 98,580
  • 191
  • 570
  • 977
27
votes
2 answers

How do I insert a blank page into a PDF with ghostscript or pdftk?

I have a PDF file that needs a blank page inserted into it every so often. The pattern is unpredictable, so I need a command that will allow me to fit one in wherever necessary. How can i do this?
ixtmixilix
  • 13,040
  • 27
  • 82
  • 118
18
votes
5 answers

How to preserve bookmarks when rearranging pages of a PDF file with tools like pdftk?

I am using pdftk to rearrange pages of a pdf file with bookmarks/outlines, but after that, the output file lost the bookmarks of the original. My command is pdftk in.pdf cat 1-22 43 23-42 44-end output out.pdf. I was wondering how I could keep the…
Tim
  • 98,580
  • 191
  • 570
  • 977
16
votes
3 answers

Printing two pages per sheet from the command line

Say I start off from a PDF document, say of 12 pages, viewed with evince. To produce another PDF of 6 sheets, with a page setup of two pages per side, I normally use the "Print to File" device listed in the ^P dialogue window. This works out…
XavierStuvw
  • 1,089
  • 6
  • 17
  • 40
10
votes
1 answer

How do I 'unbook' a pdf

I have a pdf file that was made into a booklet format. It is meant to print on A4 paper in landscape orientation; here are two pages in the pdf, which should correspond to four pages in the actual book. ------------------------------- | …
TSGM
  • 213
  • 1
  • 5
7
votes
3 answers

How can I rasterize all of the text in a PDF?

You know when you have a pdf, which is a scan of a document and it's a really huge file, because it just stores the picture of the scanned document? And there are OCR tools which can help you to make a proper document which just stores the…
7
votes
2 answers

Easiest method to create pdf from template using command line (without pdflatex)?

For ten years I have been generating billings for me and my wife in this way: Create TeX template with LyX or by hand Using in this source placeholder text Then: cat template | sed s/placeholder1/somevalue1/ |sed s/placeholder2/somevalue2 ... >…
d3k
  • 261
  • 2
  • 6
6
votes
3 answers

How to concatenate pdf files with different frame sizes

For concatenating presentations of the same topic I use pdftk (e. g. pdftk stones\ in\ england.pdf stones\ from\ namibia.pdf cat output nice\ stones.pdf). Files with diferent frame sizes but same aspect ratio are just stringed together without any…
Nepumuk
  • 659
  • 7
  • 29
6
votes
3 answers

Proper way to convert PDF to word from bash command-line

I need to convert 1K pdf files to doc on a debian server. I can convert a PDF to word using libreoffice commandline: libreoffice --headless --invisible --convert-to doc Sample-doc-file-100kb.pdf Or using soffice: soffice --nocrashreport --nologo…
user2972081
  • 161
  • 1
  • 1
  • 2
6
votes
2 answers

Overlay text in PDF via command line

The following command produced the result of the following image using convert, where an overlay box containing the letter "A" was layered over the PDF: convert online_gauss.pdf -fill white -undercolor '#00000080' -pointsize 40 -gravity South…
Bruno Silva
  • 91
  • 1
  • 5
5
votes
3 answers

How to pdftk end minus 1?

I want to exctact pages from a pdf document such that all pages are extracted except the first one and the last one. Code but (end-1) does not work, nor 2-end-1 pdftk 1.pdf cat 2-(end-1) output output.pdf
Léo Léopold Hertz 준영
  • 6,788
  • 29
  • 91
  • 193
5
votes
3 answers

pdfimages wont extract all images

I'm using pdfimages to extract images from a PDF File. I've counted at last 10 images. But the program will only extract 4. pdfimages -all file.pdf i Generates -rw-rw-r-- 1 victor victor 61389 Jul 14 21:48 i-000.png -rw-rw-r-- 1 victor…
1
2 3 4 5