Looking for more information on how to do PHP the right way? Check out PHP: The Right Way

SitePoint PHP Blog:
Filling out PDF Forms with PDFtk and PHP
Dec 03, 2015 @ 18:35:08

On the SitePoint PHP blog they've posted a tutorial from Reza Lavaryan showing how to fill out PDF forms with PDFtk and a bit of PHP on the side. PDFtk is a toolkit that provides easier handling for PDF files and content.

PDF files are one of the most common ways of sharing documents online. Whether we need to pass our clients’ documents to third-party service providers like banks or insurance companies, or just to send a CV to an employer, using a PDF document is frequently the first option.

PDF files can transfer plain/formatted text, images, hyperlinks, and even fillable forms. In this tutorial, we’re going to see how we can fill out PDF forms using PHP and a great PDF manipulation tool called PDFtk Server.

They walk you through the installation of the pdftk tool on a Homestead (Improved) virtual machine and give an overview of how it works and what makes up a PDF file. He then shows how to use PHP's exec function to make calls to the pdftk command line tool and fill in a form by editing the raw PDF content. To make it even easier he shows how to create a simple wrapper class around this that takes in the data to populate, the PDF to use and spits back out the download of the new PDF. The post ends with a quick example of extracting the current fields from the PDF, getting back more human readable output.

tagged: pdf form pdftk tutorial library populate data

Link: http://www.sitepoint.com/filling-pdf-forms-pdftk-php/


Trending Topics: