PDF Examples
From a first PDF built in code to an electronic invoice with embedded XML, the PDF examples follow the tasks of PDF processing: creating documents from code and HTML, creating and reading forms, protecting documents and checking them for accessibility. The online demos run each task on the current version; the sample projects are applications and classes that you can take further.
Online Demos
| Example | What it shows | Where |
|---|---|---|
| PDF from code | A PDF document built from scratch with ServerTextControl | Create PDFs Programmatically |
| PDF from HTML | HTML markup converted into a paginated PDF document | Create PDFs from HTML |
| ZUGFeRD invoice | A PDF/A invoice with the invoice data embedded as XML | Create a ZUGFeRD Invoice |
| Document properties | Title, author, subject and keywords added to the PDF | Set PDF Document Properties |
| Fillable forms | A form template filled with data and saved as an interactive or a flattened PDF | Create Fillable PDF Forms |
| Merging form fields | Form fields preselected with data or replaced by the merged text | Merge PDF Form Fields |
| Form data | The values of completed AcroForm fields read on the server | Extract PDF Form Data |
| Encryption | A PDF protected with passwords and access permissions | Encrypt PDF Documents |
CSV to PDF is listed in Document Processing Examples, the PDF.js demos of the viewer in Document Viewer Examples and the signing demo in Digital Signature Examples.
Sample Projects
| Example | What it shows | Where |
|---|---|---|
| Fillable PDF from an HTML form | The form fields of a template turned into an HTML form, and the submitted values merged into the template and saved as PDF, as described in Create Fillable PDFs from HTML Forms in C# ASP.NET Core Using a WYSIWYG Template. .NET 10, version 34.0 | TXTextControl.FormsToPDF |
| Watermarks per download | A watermark with data of the user added at each download, and the PDF signed so that its removal is detectable, as described in Secure by Design: Dynamic Watermarking for Enterprise Documents in C# .NET. .NET 10, version 34.0 | TXTextControl.TXEnterpriseWatermark |
| Extracted text in PDF.js | The text lines of a PDF extracted on the server and shown as overlays in a PDF.js viewer, as described in Visualizing Extracted PDF Content in a PDF.js Viewer Using TX Text Control in C# ASP.NET Core. Version 34.0 | TXTextControl.PDF.PDFJS |
| XFDF | A class that exports the AcroForm fields of a PDF as XFDF and preselects form fields from XFDF, as described in Export and Import Adobe PDF XFDF XML Files in .NET C#. The repository contains the class only | XfdfProcessing |
| HTML forms from PDF forms | The AcroForm fields of a PDF turned into HTML form elements, as described in Auto-Generate HTML Forms from PDF AcroForms in C#. Version 33.0 with the Classic engine | TextControl.Web.MVC.Core.PDFForms |
Electronic Invoice Samples
The samples below work with invoices in the ZUGFeRD, Factur-X and XRechnung formats: a PDF/A-3 document with the invoice data embedded as XML. They were written for earlier versions of TX Text Control and of the ZUGFeRD standard:
| Example | What it shows | Where |
|---|---|---|
| ZUGFeRD 2.3 | An XRechnung invoice in the ZUGFeRD 2.3 format embedded in a PDF/A-3 document, as described in Creating ZUGFeRD 2.3 (XRechnung, Factur-X) Documents with .NET C#. Version 32.0 with the Classic engine | TXTextControl.ZUGFeRD23 |
| Readable view of e-invoices | XRechnung, ZUGFeRD and Factur-X data shown as a readable document, as described in Visualize and Preview XRechnung, ZUGFeRD, and Factur-X Documents in .NET C#. Version 32.0 with the Classic engine | TXTextControl.XRechnung.Visualize |
| Invoices from a merge | XRechnung and ZUGFeRD invoices whose XML comes from the open-source ZUGFeRD-csharp library and whose readable part is created with MailMerge, as described in Creating Valid XRechnung / ZUGFeRD Invoices with ASP.NET Core C#. Version 33.0 with the Classic engine | TXTextControl.InvoiceGenerator |
Electronic Invoices in PDF/A and Attachments describe the current code.
Blog Articles With Code
| Example | What it shows | Where |
|---|---|---|
| PDF/UA validation | PDF documents checked for PDF/UA with TXTextControl.PDF.Validation, with JSON reports | Validating PDF/UA Documents in .NET C#: A Practical Guide |
| PDF/UA preflight | A document checked for the requirements of PDF/UA before it's saved | Preflighting PDF/UA Documents with TX Text Control in .NET C# |
| PDF/A for archiving | Office documents converted to PDF/A in a .NET console application on Linux | From DOCX to Long-Term Archiving: Generating PDF/A from Office Documents in .NET C# |
| PDF on Linux | PDF and PDF/A documents created in .NET on Linux | How to Create PDF Documents with TX Text Control using C# .NET on Linux |
| Forms from DOCX templates | DOCX form templates filled, flattened and exported to PDF | Programmatically Fill, Flatten, and Export DOCX Form Templates to PDF in C# .NET |
| Form fields | PDF form fields created, preselected, flattened and extracted | Create, Pre-Select, Flatten and Extract PDF Form Fields using C# |
| Encryption and permissions | Passwords and access permissions of PDF documents | PDF Security for C# Developers: Encryption and Permissions in .NET |
| Watermarks | An SVG watermark added to every page through a header | Adding Watermarks to PDF Documents in .NET C# |
| Keywords | Keywords written to and read from PDF documents for search | Enhancing PDF Searchability in Large Repositories by Adding and Reading Keywords Using C# .NET |
Next Steps
- PDF Processing: PDF creation, PDF/A, PDF/UA, forms and attachments in detail.
- Digital Signature Examples: sign the PDF documents you create.
- PDF Processing in Getting Started: create a first PDF step by step.