Centurion
Centurion

Reputation: 5291

Merge specific pdf pages with linux command using php

I want to merge some pdf files in one, the command i am using is:

gs -dBATCH -dNOPAUSE -q -sDEVICE=pdfwrite -sOutputFile=/var/www/test/pdf_merge/Merged.pdf /var/www/test/pdf_merge/1.pdf /var/www/test/pdf_merge/2.pdf /var/www/test/pdf_merge/3.pdf 

Now i want to merge specific pages in pdf, it is possible to do this with this command?

Upvotes: 1

Views: 306

Answers (2)

derfranz
derfranz

Reputation: 61

Use something like the following, where the result.pdf will have pages 1-4 from 1.pdf, the complete 2.pdf and then the 3rd page of 3.pdf:

gs -sDEVICE=pdfwrite -dNOPAUSE -dBATCH -dSAFER -sOutputFile=result.pdf -dFirstPage=1 -dLastPage=4 1.pdf 2.pdf -dFirstPage=3 -dLastPage=3 3.pdf

Upvotes: 0

hlovdal
hlovdal

Reputation: 28198

I do not know if gs supports working on individual pages (I suspect not), however there are two alternatives that have very good support for manipulating individual pdf pages.

Pdfjam (from package texlive-pdfjam-bin-2010-4.20100720.svn17868.fc15.x86_64 on my system) and pdftk.

Upvotes: 1

Related Questions