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
<PackageReference Include="AO.QuestPDF.Util" Version="1.0.4" />
<PackageVersion Include="AO.QuestPDF.Util" Version="1.0.4" />
<PackageReference Include="AO.QuestPDF.Util" />
paket add AO.QuestPDF.Util --version 1.0.4
#r "nuget: AO.QuestPDF.Util, 1.0.4"
#:package AO.QuestPDF.Util@1.0.4
#addin nuget:?package=AO.QuestPDF.Util&version=1.0.4
#tool nuget:?package=AO.QuestPDF.Util&version=1.0.4
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
XDocumentorXElement) 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 theXmlHelper.ToDocumentmethod below. - provide an extension method that works with QuestPDF's
IContainerthat 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 | Versions 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. |
-
net10.0
- QuestPDF (>= 2025.12.3)
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 |