Recipes
One task per page: a short answer and a complete program you can paste and run. Every sample is compiled and run against the library on each build of this site. The guides cover each area in depth.
Pages and documents
Section titled “Pages and documents”| Recipe | In one line |
|---|---|
| Merge PDF files | Combine several PDFs into one with PdfDocument.Merge |
| Split a PDF into one file per page | One document per page with Split |
| Extract pages from a PDF | Copy chosen pages into a new file, in any order |
| Rotate PDF pages | Turn pages by a multiple of 90 degrees |
| Add page numbers | Draw “Page 1 of 3” at the foot of every page |
| Add a watermark | A rotated, semi transparent word across every page |
Size and quality
Section titled “Size and quality”| Recipe | In one line |
|---|---|
| Reduce PDF size for email | Downsample oversized images and store photographs as JPEG |
| Downsample images in a PDF | Bring every image down to the resolution it is shown at |
| Linearize a PDF for fast web view | Show the first page before the whole file has downloaded |
| Batch compress PDFs from the command line | A whole folder with pdfnetstack batch and a CSV report |
| Check two PDFs for equivalence | Prove another tool’s output holds the same document |
Security, forms and archiving
Section titled “Security, forms and archiving”| Recipe | In one line |
|---|---|
| Password protect a PDF | AES-256 with user and owner passwords and permissions |
| Remove a password from a PDF | Open with the owner password and save unprotected |
| Fill and flatten a PDF form | Set field values, then stamp them into the page |
| Flatten annotations | Make comments, highlights and stamps part of the page |
| Add a signature field | An empty box for a signer to sign in their viewer |
| Create a Factur-X invoice | A PDF/A-3 e-invoice with its XML and Factur-X metadata |
Content
Section titled “Content”| Recipe | In one line |
|---|---|
| Convert an HTML invoice to PDF | HTML and CSS to PDF with page numbers, no browser |
| Convert a TIFF to PDF | Every page of a multi-page TIFF on its own PDF page |
| Write Arabic text in a PDF | Right to left text with joined letters, searchable |
| Extract all images from a PDF | JPEGs as stored, other images as PNG |
| Make a scanned PDF searchable | OCR with the PdfNetStack.Ocr add-on |
Recipes marked 1.1 need the 1.1 packages or later.