Other utilities⚓︎
PyPDFForm offers additional utilities similar to other PDF libraries.
This section of the documentation uses this PDF as an example.
Blank PDFs⚓︎
Use the BlankPage class with PdfWrapper to create blank PDFs.
The following example generates a PDF with a single blank page:
By default, BlankPage creates a letter-size blank page (612 x 792 points, or 8.5 x 11 inches). To change the dimensions, specify width and height in points:
Extract pages⚓︎
Warning
Each page is extracted on its own, without content from other pages. Links and other actions that go to another page, such as a navigation button's, are removed, even when that page is extracted too. A field shared with other pages keeps only its widgets on the extracted page.
Extraction raises a ValueError if a page refers to another page's content in any other way, such as a button that resets a field on another page.
Extraction is not redaction. Content the extracted page uses itself, including resources it shares with other pages, is kept.
The PdfWrapper object has a .pages attribute, which is a PdfArray containing one PdfWrapper object per page:
Merge multiple PDFs⚓︎
Note
When merging PDF forms with duplicate field names, PyPDFForm automatically renames conflicting fields by appending a unique, randomly generated suffix. This means some field names in the merged PDF will differ from their original names.
To avoid automatic renaming, give duplicate fields unique names across all input PDFs before merging. See Change field name.
You can merge multiple PDF files by adding their PdfWrapper objects together. For example, to merge this PDF and this PDF:
When merging a large number of PDF files, use the PdfArray.merge method for better performance. It always returns a new PdfWrapper, which is empty when the array is empty:
For CLI merges, pass the input PDFs to create merge:
Change PDF version⚓︎
PyPDFForm allows you to set the PDF version to any supported value up to 2.0: