AO.QuestPDF.Util 1.0.4

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

QuestPDF is a really neat library. But in my situation, I need the ability to insert HTML snippets into PDFs, which is not supported functionality. See QuestPDF issue 134. To be fair, converting HTML to PDF is wildly complicated if you want to support every CSS feature. There are paid libraries from Syncfusion, for example, that do this. But these libraries tend to have large dependency footprints and do way more than I need.

Fortunately, my requirements are pretty modest. This project represents my attempt at PDF conversion from HTML, supporting a very small feature set. There are two main things I needed to do:

  • get an XML document (in the form of XDocument or XElement) from a string, with some forgiveness built-in for certain malformed tags. In my use case, the HTML is not perfectly XHTML-compliant. But I needed a valid XML document before attempting any conversion. This is the XmlHelper.ToDocument method below.
  • provide an extension method that works with QuestPDF's IContainer that does the actual conversion.

See this in use in my test method. Note that I couldn't seem to get a real unit test working with a binary comparison of expected and actual PDF outputs. It appears that there are always minor differences between outputs of the same PDF. I've seen this symptom in other PDF libraries, so I figure this is just how it is with PDFs. In any case, I was pretty happy to get this much working.

Reference

QuestPdfUtil.QuestPdfHelper QuestPdfHelper.cs

  • void Html (this IContainer container, XDocument document, [ Action<TextSpanDescriptor> spanAction ])
  • void Html (this IContainer container, string html, [ Dictionary<string, string> replacements ], [ Action<TextSpanDescriptor> spanAction ])
  • void Html (this IContainer container, XElement element, [ Action<TextSpanDescriptor> spanAction ])

QuestPdfUtil.XmlHelper XmlHelper.cs

  • XDocument ToDocument (string input, [ string defaultEnclosingTag ], [ Dictionary<string, string>? replacements ])
Product Compatible and additional computed target framework versions.
.NET net10.0 is compatible.  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.4 248 1/25/2026