Code Samples & Examples

Real-world examples showing how to build PDFs with TerraPDF. From simple reports to complex documents with tables, encryption, and advanced layouts.

01. Simple Report

Beginner

Text formatting, bold/italic/strikethrough, justified paragraphs, horizontal rules, tables with alternating rows, and page numbers.

Text Spans Tables Page Numbers
View Sample

02. Styled Newsletter

Intermediate

Two-column layouts, colored banners, pull-quote blocks, statistics boxes with borders, and multi-page repeating footers.

Columns & Rows Styling Borders
View Sample

03. Invoice

Intermediate

Multi-page document with 30-row line-items table, repeating header on every page, bill-from/to sections, totals block, and payment terms.

Multi-Page Table Headers Images
View Sample

04. Company Profile

Intermediate

Full-width header banner images, team tables, key metrics, service cards, and multi-page layouts with footer logos.

Images Metrics Layout
View Sample

05. Event Brochure

Intermediate

Conference agenda tables, speaker cards in two-column layout, sponsor logos grid, and call-to-action banners.

Agenda Cards Sponsors
View Sample

06. Product Catalogue

Advanced

Complex multi-page product grid with images, descriptions, pricing, availability status, and category filtering.

Product Grid Images Pricing
View Sample

07. Product Catalog Cover

Advanced

Professional cover page design with featured products, testimonials, and promotional content layout techniques.

Design Cover Page Testimonials
View Sample

08. Report with Bookmarks

Advanced

Hierarchical bookmark structure with top-level sections, sub-sections, and page-positioned entries for easy PDF navigation.

Bookmarks Navigation Hierarchy
View Sample

09. Report with Table of Contents

Advanced

Automatic table of contents generation with heading levels (H1-H6), clickable page numbers, and internal links between sections.

TOC Headings Links
View Sample

10. Vector Graphics Showcase

Advanced

Demonstrates drawing capabilities including shapes, lines, gradients, and custom vector graphics for data visualization.

Graphics Shapes Visualization
View Sample

11. Unicode Showcase

Advanced

Comprehensive Unicode and multi-language support, including RTL text, special characters, and various scripts and encodings.

Unicode RTL Encoding
View Sample

12. Encryption & Security

Advanced

AES-128 password protection with four scenarios: open password, owner-only, print-only, and fully restricted documents.

Encryption Permissions Security
View Sample

Getting the Sample Source Code

All samples are part of the TerraPDF repository and can be run locally.

git clone https://github.com/sahebansari/TerraPDF.git
cd TerraPDF/samples/TerraPDF.Sample
dotnet run

The samples will generate PDF files to your Desktop in a SamplePDF folder. Each sample demonstrates different TerraPDF features and can be modified to suit your needs.