Examples UniPDF
Starting from an example can speed up code development significantly.
Examples
Starting from an example can speed up code development significantly. Start from one of our provided examples, or contact us via [email protected] if the example you need is not provided.
The examples are also available on our UniPDF Examples repository:
Title | Description |
---|---|
Generate PDF reports | Demonstrates many of the common components used when creating a PDF report with UniPDF. Great starting point for creating advanced reports. |
Crop pages | Demonstrates how to crop the MediaBox of a page in a PDF document using UniPDF. |
Merge PDFs | Simply loads all pages for each file and writes to the output file. |
Advanced merging | For a more basic merging of PDF page contents, see pdf_merge.go |
Page info | Prints PDF page info: Mediabox size and other parameters |
Rotate page | Rotate pages in a PDF file. Degrees needs to be a multiple of 90 |
Split PDF | Basic PDF split example: Splitting by page range |
Advanced splitting | Advanced PDF split example: Takes into account optional content - OCProperties (rarely used) |
Insert image to PDF | Adds image to a specific page of a PDF. xPos and yPos define the upper left corner of the image location, and width |
Extract images from PDF as ZIP | Extract images from a PDF file. Passes through each page, goes through the content stream and finds instances of both |
Convert images to PDF | Add images to a PDF file, one image per page |
List of all images in PDF | List images in a PDF file. Passes through each page, goes through the content stream and finds instances of both |
Watermark PDF | Add watermark image to each page of a PDF file |
Insert QR code | Create a barcode or a QR code and insert on a specific location in a PDf file |
Insert barcode | Create a barcode and insert on a specific location in a PDf file |
Check access permissions | Check access permissions for a specified PDF |
Protect PDF | Protects PDF files by setting a password on it. This example both sets user and opening password and hard-codes the protection bits here, but easily adjusted in the code here although not on the command line. |
Unlock PDF - remove password | Unlocks PDF files, tries to decrypt encrypted documents with the given password, if that fails it tries an empty password as best effort. |
Get PDF security info | Outputs protection information about locked PDFs. |
Extract text from PDF | PDF to text: Extract all text for each page of a pdf file. |
Detect certain text in PDF | Basic example for text searching: Retrieving position of a signature line in PDF where the signature line is given by text. And positioned with a Tm operation above. |
Insert text to PDF | Insert text to a specific page, location in a PDF file. |
Draw line to PDF | Draw a line in a new PDF file. |
List of form fields | Lists form fields in a PDF file. |
Detect scanned PDF | Detect scanned PDF files by looking through the object types and determining whether it is likely to be a scanned file. |
Get PDF object | Get specific object from a PDF by number. Prints the trailer dictionary if no number specified. |
Basic PDF info | Prints basic PDF info: number of pages and encryption status. |
Inspect PDF objects | Inspect PDF object types. This example shows the capability of assessing the object types in PDF files. |
Print content streams | List all content streams for all pages in a pdf file. |
Annotate ellipse | Annotate/mark up pages of a PDF file. |
Annotate line | Add a line with arrowhead between two specified points on a page. |
Annotate rectangle | Add a rectangle annotation to a specified location on a page. |
Annotate w/text | Adds a text annotation with a user specified string to a fixed location on every page. |
List annotations | Lists annotations in a PDF file. |
Convert PDF to grayscale | Convert a PDF to grayscale in a vectorized fashion, including images and all content. |