Merge and split PDF in PHP using PDFtk
December 21, 2012
- PDFtk runs on a variety of platforms, including: Windows, Linux, Mac OSX, FreeBSD and Solaris.
- It does not require Acrobat and allows you to manipulate PDF easily and freely.
What all you can do in PHP using PDFtk
- Merge PDF documents to one.
- Rotate PDF Pages or documents.
- Split the pages of the PDF into a new document.
- Encrypt the output as desired.
- Decrypt the Input as necessary but requires password
- Background watermark or a foreground stamp can be applied
- Report on PDF metrics can be generated such as metadata, bookmarks, and page labels.
- Update PDF metadata.
- Attach numerous files to the PDF document.
- Compress a PDF document into a single page.
Under the GPL, PDFtk is licensed for the public.
Download Link: https://github.com/bensquire/php-pdtfk-toolkit
You can provide two or more PDF files as arguments to create single PDF file as output.
Merge two or more PDFs into a new PDF file with all the original contents
- pdftk example1.pdf example2.pdf example3.pdf cat output result.pdf
Rotate the first page of a PDF to 90 degrees clockwise
- pdftk in.pdf cat 1E 2-end output out.pdf
Rotate all the pages of the PDF document by 180 degrees
- pdftk in.pdf cat 1-endS output out.pdf
Report on PDF document metadata, bookmarks and page labels
- pdftk mydoc.pdf dump_data output report.txt