Examples  UniPDF

Starting from an example can speed up code
development significantly.

arrow&v
Title
Description
Convert PDF to grayscale
Convert a PDF to grayscale in a vectorized fashion, including images and all content.
List annotations
Lists annotations in a PDF file.
Annotate w/text
Adds a text annotation with a user specified string to a fixed location on every page.
Annotate rectangle
Add a rectangle annotation to a specified location on a page.
Annotate line
Add a line with arrowhead between two specified points on a page.
Annotate ellipse
Annotate/mark up pages of a PDF file.
Print content streams
List all content streams for all pages in a pdf file.
Inspect PDF objects
Inspect PDF object types. This example shows the capability of assessing the object types in PDF files.
Basic PDF info
Prints basic PDF info: number of pages and encryption status.
Get PDF object
Get specific object from a PDF by number. Prints the trailer dictionary if no number specified.
Detect scanned PDF
Detect scanned PDF files by looking through the object types and determining whether it is likely to be a scanned file.
List of form fields
Lists form fields in a PDF file.
Draw line to PDF
Draw a line in a new PDF file.
Insert text to PDF
Insert text to a specific page, location in 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.
Extract text from PDF
PDF to text: Extract all text for each page of a pdf file.
Get PDF security info
Outputs protection information about locked PDFs.
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.
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.
Check access permissions
Check access permissions for a specified PDF
Insert barcode
Create a barcode and insert on a specific location in a PDf file
Insert QR code
Create a barcode or a QR code and insert on a specific location in a PDf file
Watermark PDF
Add watermark image to each page of a PDF file
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
Convert images to PDF
Add images to a PDF file, one image per page
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
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
Advanced splitting
Advanced PDF split example: Takes into account optional content - OCProperties (rarely used)
Split PDF
Basic PDF split example: Splitting by page range
Rotate page
Rotate pages in a PDF file. Degrees needs to be a multiple of 90
Page info
Prints PDF page info: Mediabox size and other parameters
Advanced merging
For a more basic merging of PDF page contents, see pdf_merge.go
Merge PDFs
Simply loads all pages for each file and writes to the output file.
Crop pages
Demonstrates how to crop the MediaBox of a page in a PDF document using UniPDF.
Generate PDF reports
Demonstrates many of the common components used when creating a PDF report with UniPDF. Great starting point for creating advanced reports.