Adding a field to a PDF file when merging using PDFTK or similar

I have a large collection of half-page PDF flyers that are stored in a folder on my Linux server. A user on the site will want to create a booklet from a subset . The booklet will be attached, so even pages in the collection will want to get more fields on the right side, and on odd pages there will be more fields on the left side. A collection of 500 universes can have up to 200 pages, so I don’t want to regenerate each page to install it. Running content through DOMPDF will take too much time for the servers. Simple document creation with PDFTK is fast.

I would like to combine a document with PDFTK from a centered PDF file and add the appropriate margin for an odd or even page.

If there is no PDFTK, is there another tool that could do the job?

+5
source share
3 answers

If you are using ubuntu, you can install pdfcrop:

sudo apt-get install -y pdfcrop

Despite its name, it pdfcrophas the ability to add fields:

pdfcrop --margin '29 0 29 0' input.pdf output.pdf

(Note: unit is 72 pp = 1 inch. 29 bp is approximately 1 cm.)

Then use pdfjamoffsets for the left and right pages to perform the trick.

pdfjam --twoside --offset '1cm 0cm' file.pdf

Note: pdfcrop has problems with some pdf files. (!!! Error: Ghostscript exited with error code 139!).

+9
source

, pdfjam, PDF . , -

pdfjam --twoside --offset '2cm 0cm' file.pdf

2 , - .
pdfjam pdfpages pdflatex.

+3

Even if it's a little late, but it can help someone. In response to the @ElkeSpaak comment, this is a package texlive-extra-utils:

dpkg-query -S /usr/bin/pdfcrop 
texlive-extra-utils: /usr/bin/pdfcrop
+1
source

All Articles