Introduction
Welcome to the world of dynamically built PDF documents!
In today’s web applications, the Portable Document Format is commonly used to send invoices, reports, tickets, e-books, printed materials and many other files. Chances are that you are already working in a project that requires processing PDF files for users.
I have over ten years of experience with the PDF and now I’m going to share everything, so that you can save time, avoid common pitfalls and learn more!
Who is this book for?
If you’re reading this, you’re most likely a PHP developer looking for help with processing PDF files. You probably need to dynamically create documents and you don’t know where to start. Perhaps you also need to transform existing documents to text or images, or do any other sort of editing.
You might already have some experience with PDF processing, but you’re searching for a more in-depth explanation. You’re struggling with different tools and you’re not sure which one is perfect for the job.
You should have basic programming skills with PHP. Experience with using Composer is highly recommended as this is the primary tool to load external libraries into your project. Also, basic knowledge of the Unix shell will be useful.
This book is not tied to any particular framework, however we might use some components coming from popular frameworks. Users of all frameworks are welcome here, just like people who code plain PHP.
How to read this book?
Chapters 2 and 3 provide explanations about the Portable Document Format itself. First you’ll learn about the features offered by subsequent versions of the format. You’ll know the differences between PDF versions. This will let you speak more freely with your business clients about possibilities of the PDF. You’ll also know what to expect from the tools you will be using.
Chapter 3 is an in-depth look into the internal structure of a PDF file. For most basic tasks you won’t need to know it. However, some advanced processes require basic understanding of how a PDF is made. You will see why it can be so difficult to extract meaningful data from a PDF by a program.
Later, we will look at different tools to generate PDF documents. You’ll know the pros and cons of several solutions, both native libraries and binary tools. You can treat chapter 5 as a cheat sheet to quickly choose the best tool for your needs, both feature and performance-wise.
In chapter 6 you will learn about different ways to share a document with a user. Reading inside a browser window, downloading, emailing, cloud uploads - every business case may require something else. Know your options.
I’m also going to describe advanced topics like CSS Paged Media and Generated Content. These specifications allow you to create professional paged documents and books with a simple HTML and CSS syntax.
This book ends with several guides about processing existing documents. You’ll learn how to extract text, metadata and other objects from a PDF. You’ll also perform splitting, joining, watermarking and other editing tasks.
About the author
I’m a software developer mostly with a PHP and Java background. I started my professional career in 2008, just before a global economic crisis hit. I survived and then learnt a lot about different industries I worked for: media, advertising, education and finance.
I’ve been sharing my programming knowledge since I was a teenager. Back in 2002 I started my adventure with a Polish e-zine, when dial-up connections were still the main way of browsing the internet. I often stopped my parents from making phone calls when I wanted to surf the Web. Sometimes, they had to pay terrifying bills for my online time.
The internet kept growing rapidly. Unfortunately I had to stay a bit in the back and finish my formal education. Then I took an ordinary job and as a 19-year-old young man, I did everything my bosses wanted me to do.
When I gathered enough professional experience, I decided to share it. I started my Twitter profile and my blog. I gave talks at meetups and conferences. I’m still doing it today and I hope you will all benefit from my work!