Creating and copying PDF documents
Working with PDFs adds more value when you can create them from scratch programmatically. Let's see how we can create our own PDF files in this section.
We will continue to use the
PyPDF2 module for this recipe and will deal with its
PdfFileMerger classes. We will also use another module,
fpdf, to demonstrate adding content to PDF files. We will talk about this later in the recipe.
How to do it...
- We can create a PDF file in multiple ways; in this example, we copy the contents of an old file to generate a new PDF file. We start by taking an existing PDF--
Exercise.pdf. The following screenshot shows the contents of this file. It contains two pages; the first page is a technical exercise ...