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
BeginnerText formatting, bold/italic/strikethrough, justified paragraphs, horizontal rules, tables with alternating rows, and page numbers.
02. Styled Newsletter
IntermediateTwo-column layouts, colored banners, pull-quote blocks, statistics boxes with borders, and multi-page repeating footers.
03. Invoice
IntermediateMulti-page document with 30-row line-items table, repeating header on every page, bill-from/to sections, totals block, and payment terms.
04. Company Profile
IntermediateFull-width header banner images, team tables, key metrics, service cards, and multi-page layouts with footer logos.
05. Event Brochure
IntermediateConference agenda tables, speaker cards in two-column layout, sponsor logos grid, and call-to-action banners.
06. Product Catalogue
AdvancedComplex multi-page product grid with images, descriptions, pricing, availability status, and category filtering.
07. Product Catalog Cover
AdvancedProfessional cover page design with featured products, testimonials, and promotional content layout techniques.
08. Report with Bookmarks
AdvancedHierarchical bookmark structure with top-level sections, sub-sections, and page-positioned entries for easy PDF navigation.
09. Report with Table of Contents
AdvancedAutomatic table of contents generation with heading levels (H1-H6), clickable page numbers, and internal links between sections.
10. Vector Graphics Showcase
AdvancedDemonstrates drawing capabilities including shapes, lines, gradients, and custom vector graphics for data visualization.
11. Unicode Showcase
AdvancedComprehensive Unicode and multi-language support, including RTL text, special characters, and various scripts and encodings.
12. Encryption & Security
AdvancedAES-128 password protection with four scenarios: open password, owner-only, print-only, and fully restricted documents.
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.