zPdfGenerator 0.1.7

dotnet add package zPdfGenerator --version 0.1.7
                    
NuGet\Install-Package zPdfGenerator -Version 0.1.7
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="zPdfGenerator" Version="0.1.7" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="zPdfGenerator" Version="0.1.7" />
                    
Directory.Packages.props
<PackageReference Include="zPdfGenerator" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add zPdfGenerator --version 0.1.7
                    
#r "nuget: zPdfGenerator, 0.1.7"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package zPdfGenerator@0.1.7
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=zPdfGenerator&version=0.1.7
                    
Install as a Cake Addin
#tool nuget:?package=zPdfGenerator&version=0.1.7
                    
Install as a Cake Tool

zPdfGenerator

License: MIT NuGet NuGet (pre)

A lightweight, fluent, and extensible PDF generation toolkit for .NET.
It provides two high-level generators:


Available Generators

1️ FormPdfGenerator (AcroForm PDF filler)

Fills existing PDF form templates (AcroForms) with strongly-typed data models using a fluent builder and placeholder system.

2️ FluidHtmlPdfGenerator (HTML → PDF renderer)

Will generate PDF documents from Fluid HTML templates and a strongly typed model.


Features

Shared features (both generators)

  • Fluent API with strongly-typed placeholders
  • Automatic culture-aware formatting (dates, numbers, currencies)
  • Based on .NET 6+
  • Extensible design — add custom placeholders easily
  • Built-in logging via ILogger<T>
  • Supports cancellation tokens
  • Fully testable and mockable

Installation

dotnet add package zPdfGenerator

Required for FormPdfGenerator

dotnet add package itext
dotnet add package itext.forms
dotnet add package itext.bouncy-castle-adapter

Required for HtmlPdfGenerator

dotnet add package itext.html2pdf
dotnet add package FluidCore

FormPdfGenerator

FormPdfGenerator fills PDF AcroForms using a fluent builder and placeholder mapping.

Example Model

public class CustomerInfo
{
    public string Name { get; set; }
    public DateTime? BirthDate { get; set; }
    public decimal? Balance { get; set; }
    public decimal? Total { get; set; }
    public string Currency { get; set; }
}

Simple Example

var pdf = new FormPdfGenerator(logger);

byte[] bytes = pdf.GeneratePdf<CustomerInfo>(builder =>
{
    builder
        .UseTemplatePath("templates/Contract.pdf")
        .UseCulture(new CultureInfo("es-ES"))
        .SetData(customer)

        .AddText("Name", c => c.Name)
        .AddDate("BirthDate", c => c.BirthDate, "dd/MM/yyyy")
        .AddNumeric("Balance", c => c.Balance, "N2")
        .AddNumericAndText(
            "TotalWithCurrency",
            c => new NumericAndTextValue(c.Total, c.Currency))

        .AddFormElementsToRemove("OptionalSignature");
});

File.WriteAllBytes("ContractCompleted.pdf", bytes);

Examples of Use

Example 1: Basic text fields

builder
    .SetData(order)
    .AddText("OrderNumber", o => o.OrderNumber)
    .AddText("CustomerName", o => o.CustomerName)
    .AddText("Notes", o => o.Comments);

Example 2: Date formatting with culture

builder
    .UseCulture(new CultureInfo("es-ES"))
    .AddDate("IssueDate", o => o.CreatedAt, "dd MMMM yyyy")
    .AddDate("ExpiryDate", o => o.ExpiresAt, "dd/MM/yyyy");

Example 3: Numeric formatting

builder
    .UseCulture(new CultureInfo("de-DE"))
    .AddNumeric("Amount", o => o.Amount, "N2")
    .AddNumeric("TaxRate", o => o.TaxRate, "P1");

Example 4: Composite numeric + text placeholder

builder.AddNumericAndText(
    "AmountCurrency",
    o => new NumericAndTextValue(o.Total, o.CurrencyCode),
    "N2"
);

Example 5: Removing form fields dynamically

builder.AddFormElementsToRemove("DebugField", "UnusedField");

Example 6: Full configuration

var pdfBytes = generator.GeneratePdf<Invoice>(builder =>
{
    builder
        .UseTemplatePath("templates/Invoice.pdf")
        .UseLicenseFile("licenses/itextkey.json")
        .UseCulture(new CultureInfo("en-US"))
        .SetData(invoice)

        .AddText("InvoiceNumber", i => i.Number)
        .AddText("CustomerName", i => i.Customer.Name)
        .AddText("Address", i => i.Customer.Address)
        .AddDate("InvoiceDate", i => i.Date, "MMMM dd, yyyy")
        .AddNumeric("Total", i => i.Total, "C2")
        .AddNumericAndText(
            "TotalInWords",
            i => new NumericAndTextValue(i.Total, i.CurrencyCode))

        .AddFormElementsToRemove("OptionalCommentField", "InternalNotes");
});

Placeholder System Overview

Placeholder Type Maps From Output
TextPlaceHolder<T> Func<T, string> Raw text
NumericPlaceHolder<T> Func<T, decimal?> Formatted number
DateTimePlaceHolder<T> Func<T, DateTime?> Formatted date
NumericAndTextPlaceHolder<T> Func<T, NumericAndTextValue> Composite (e.g., "1,234.00 EUR")

Unit Testing

Creating a template programmatically:

var form = PdfFormCreator.GetAcroForm(pdf, true);

new TextFormFieldBuilder(pdf, "Name")
    .SetWidgetRectangle(new Rectangle(50, 750, 200, 20))
    .CreateText();

Reading values:

var form = PdfAcroForm.GetAcroForm(pdf, false);
var fields = form.GetAllFormFields();

string name = fields["Name"].GetValueAsString();

FluidHtmlPdfGenerator

The future HTML engine renders PDFs directly from a Fluid HTML templates.

Features

  • Fluid support
  • Strongly typed model binding
  • Shared placeholder API
  • Embedded assets (CSS, fonts, images)
  • Page layout configuration (margins, headers, footers)

Example

var pdf = new FluidHtmlPdfGenerator(logger, new HtmlToPdfConverter());

byte[] output = pdf.GeneratePdf(model, builder =>
{
    builder
        .UseHtmlTemplate("templates/Invoice.html")
        .AddText("CustomerName", m => m.Name)
        .AddNumeric("Total", m => m.Total);
});

Requirements

  • netstandard 2.1 or higher (compatible with .NET and .NET Framework 4.7.2+)
  • iText 8
  • BouncyCastle Adapter
  • A fillable PDF AcroForm template (for FormPdfGenerator)
  • A fillable Fluid HTML template and CSS (for FluidHtmlPdfGenerator)

License

MIT License for this library.

iText itself is AGPL unless you have a commercial license.


Contributing

  1. Fork the repository
  2. Create a feature branch
  3. Add tests
  4. Submit a PR

Support

Open an issue if you need help with:

  • Custom placeholders
  • Checkbox, radio, dropdown binding
  • HTML template rendering
  • Multi-page PDF generation
  • Export pipelines
Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
.NET Core netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.1 is compatible. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on zPdfGenerator:

Package Downloads
zPdfGenerator.Charts

A library for building charts for Pdf reports with iText through a fluent API.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
0.1.7 228 12/19/2025
0.1.6 300 12/18/2025
0.1.5 258 12/17/2025
0.1.4 227 12/15/2025
0.1.3 228 12/15/2025
0.1.2 228 12/15/2025
0.1.1 165 12/5/2025
0.1.0 175 12/5/2025