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/

Joshua Thjissen:
Understanding Symfony2 Forms
Sep 14, 2015 @ 14:28:50

Joshua Thjissen has a post on his site that wants to help you understand the basics of Symfony2 forms including how to build them, extend them and the modules they're made up of.

To actually use Symfony2 forms, all you need to do is read some documentation, a few blog posts and you’ll be up and running in a couple of minutes. Understanding Symfony2 forms however, is a whole different ballgame. In order to understand a seemingly simple process of “adding fields to a form”, we must understand a lot of the basic foundation of the Symfony2 Form component. In these blog posts, I’ll try and give some more insights on this foundation.

He starts by explaining the three main steps in the typical form lifecycle: building the form itself, populating and validating data and rendering the form to the waiting user. He then gets into some of the basics of using forms and the types of objects that make them up. He includes examples of creating a simple form, the YAML configuration it compiles to and the functions used to build, render and set options on the form. He finishes up the post looking at form inheritance, extending the form types and where the "ResolvedFormType" comes in to play.

tagged: symfony2 form understand overview types build render validate populate

Link: https://www.adayinthelifeof.nl/2015/09/11/understanding-symfony2-forms/

Eirik Hoem's Blog:
Populate PDF templates with PHP / FPDF / FPDI
May 08, 2008 @ 16:11:55

Eirik Hoem recently pointed out two libraries that can be used in PHP to generate PDF files dynamically - FPDF and FPDI.

Ever wanted to generated PDF documents on the fly with PHP? Perhaps populate a standard contract with a customers name and address? FPDF and FPDI are two neat libraries which greatly helps when working with PDF files.

FPDF handles most of the work of creating and working with the PDF files while FPDI works together with it to pull in existing PDF files so FPDF can modify them. He links to some sample code you can try out once you've installed the two libraries.

tagged: pdf generate fpdf fpdi template populate

Link:


Trending Topics: