ZingPDF.Templates.LiquidHtml 1.0.60

dotnet add package ZingPDF.Templates.LiquidHtml --version 1.0.60
                    
NuGet\Install-Package ZingPDF.Templates.LiquidHtml -Version 1.0.60
                    
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="ZingPDF.Templates.LiquidHtml" Version="1.0.60" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="ZingPDF.Templates.LiquidHtml" Version="1.0.60" />
                    
Directory.Packages.props
<PackageReference Include="ZingPDF.Templates.LiquidHtml" />
                    
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 ZingPDF.Templates.LiquidHtml --version 1.0.60
                    
#r "nuget: ZingPDF.Templates.LiquidHtml, 1.0.60"
                    
#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 ZingPDF.Templates.LiquidHtml@1.0.60
                    
#: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=ZingPDF.Templates.LiquidHtml&version=1.0.60
                    
Install as a Cake Addin
#tool nuget:?package=ZingPDF.Templates.LiquidHtml&version=1.0.60
                    
Install as a Cake Tool

ZingPDF logomark

ZingPDF.Templates.LiquidHtml

ZingPDF.Templates.LiquidHtml creates PDFs from Liquid HTML templates. It uses Fluid for Liquid rendering and ZingPDF.FromHTML for HTML-to-PDF conversion.

.NET compatibility

Targets net8.0, with .NET 8 as the minimum. Runtime validation covers .NET 8, 9, and 10 on Windows. .NET Framework 4.x and applications targeting .NET 6 or 7 are not supported. Native dependencies and deployment requirements remain package-specific. See runtime and platform requirements.

Installation

dotnet add package ZingPDF.Templates.LiquidHtml

Quick start

Render a Liquid HTML template file to PDF:

using ZingPDF.Templates.LiquidHtml;

var invoice = new
{
    Number = "INV-1001",
    CustomerName = "Ada Lovelace",
    Items = new[]
    {
        new { Description = "Consulting", Total = 240m },
        new { Description = "Support", Total = 80m }
    }
};

await using var output = File.Create("invoice.pdf");

await LiquidHtmlPdfTemplate
    .FromFile("invoice.liquid.html")
    .RenderAsync(invoice, output);

The template can use Liquid variables, loops, and conditionals:

<!doctype html>
<html>
  <body>
    <h1>Invoice {{ Number }}</h1>
    <p>{{ CustomerName }}</p>

    <table>
      {% for item in Items %}
      <tr>
        <td>{{ item.Description }}</td>
        <td>{{ item.Total }}</td>
      </tr>
      {% endfor %}
    </table>
  </body>
</html>

Share a configured browser

The invoice model above can use a caller-owned renderer. Pass the application cancellation token through RenderAsync.

using ZingPDF.FromHTML;
using ZingPDF.Templates;
using ZingPDF.Templates.LiquidHtml;

await using var renderer = new HtmlToPdfRenderer(new HtmlToPdfOptions
{
    BrowserExecutablePath = Environment.GetEnvironmentVariable("ZINGPDF_BROWSER_PATH")
        ?? throw new InvalidOperationException("Set ZINGPDF_BROWSER_PATH to an installed browser.")
});

var template = LiquidHtmlPdfTemplate.FromSource(
    PdfTemplateSource.FromFile("invoice.liquid.html"),
    new RendererHtmlToPdfConverter(renderer));

await using var output = File.Create("invoice.pdf");
await template.RenderAsync(invoice, output, cancellationToken: cancellationToken);

The converter receives the cancellation token after Liquid rendering and uses the renderer's concurrency, deadline and print settings. The renderer deadline starts at browser conversion; it does not include Liquid rendering. Liquid parsing and rendering are not an interruptible OS-level workload.

For paginated invoices, define @page, a thead with display: table-header-group, and break-inside: avoid on rows. Keep totals outside repeating table footers. See examples/GenerateInvoices for 0, 1, 40 and 500 line items, repeated headers, totals and embedded fonts.

Notes

  • Supply BrowserExecutablePath for an installed Chromium-compatible browser. AllowBrowserDownload defaults to false; enable it explicitly only if runtime downloading is intended.
  • Reuse one HtmlToPdfRenderer across jobs. It owns one browser and creates an isolated browser context for each conversion. MaxConcurrency defaults to 4; additional jobs queue.
  • RenderTimeout defaults to 30 seconds and covers queueing, browser startup, page loading, font readiness and PDF printing. Set it to Timeout.InfiniteTimeSpan to disable the overall deadline. BrowserStartupTimeout independently limits browser provisioning and launch to 30 seconds by default and must remain finite. Expiry throws TimeoutException; caller cancellation throws OperationCanceledException. Context creation and cleanup must complete to release resources; browser startup or downloading can remain renderer-owned after a caller stops waiting, within the separate startup budget. Disposal cancels browser provisioning. The deadline is not an OS-enforced hard worker bound.
  • The renderer snapshots options, including print options and launch arguments, at construction. The caller disposes the renderer and returned streams; templates and their converter adapter do not own the renderer.
  • New renderer defaults use print media, background printing and CSS page sizes. Set PdfOptions for paper, margins, page ranges or headers/footers. Original static Converter.ToPdfAsync(...) overloads retain automatic browser downloading, screen media and default PuppeteerSharp print settings. They disable the overall conversion deadline so explicit navigation timeouts, including zero, remain effective; the independent browser startup budget still defaults to 30 seconds. The overload taking HtmlToPdfOptions uses explicit settings for one job.
  • Offline = true emulates offline page networking. Embed fonts and images as data URLs. This setting is not an OS-level network sandbox or a security guarantee.
  • HTML and scripts must be trusted. Isolated browser contexts separate job state; they do not sandbox hostile code at the process or network boundary. The renderer does not disable Chromium's sandbox by default.
  • File-backed templates resolve Liquid includes from the template directory by default.
  • Use RenderHtmlAsync(...) to inspect rendered HTML before PDF conversion.
  • Default FromFile, FromString and single-argument FromSource use the original static converter settings. Select the two-argument FromSource overload to control browser deployment and printing.

More information

Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.0.60 94 11/3/2026
1.0.59 125 10/11/2026
1.0.58 262 5/28/2026
1.0.57 140 5/25/2026
1.0.56 137 5/15/2026