OfficeIMO.Html.Pdf
2.0.1
Prefix Reserved
dotnet add package OfficeIMO.Html.Pdf --version 2.0.1
NuGet\Install-Package OfficeIMO.Html.Pdf -Version 2.0.1
<PackageReference Include="OfficeIMO.Html.Pdf" Version="2.0.1" />
<PackageVersion Include="OfficeIMO.Html.Pdf" Version="2.0.1" />
<PackageReference Include="OfficeIMO.Html.Pdf" />
paket add OfficeIMO.Html.Pdf --version 2.0.1
#r "nuget: OfficeIMO.Html.Pdf, 2.0.1"
#:package OfficeIMO.Html.Pdf@2.0.1
#addin nuget:?package=OfficeIMO.Html.Pdf&version=2.0.1
#tool nuget:?package=OfficeIMO.Html.Pdf&version=2.0.1
OfficeIMO.Html.Pdf
OfficeIMO.Html.Pdf converts HTML directly to PDF with the same first-party layout scene used by HTML-to-PNG and HTML-to-SVG. It also converts PDF to semantic or positioned-review HTML.
The HTML-to-PDF path has no browser process, Office automation, Markdown bridge, Word bridge, or new external dependency.
Install
dotnet add package OfficeIMO.Html.Pdf
HTML to PDF
using OfficeIMO.Html;
using OfficeIMO.Html.Pdf;
string html = """
<h1>Quarterly update</h1>
<p>Generated directly by OfficeIMO.</p>
<table>
<tr><th>Area</th><th>Status</th></tr>
<tr><td>PDF</td><td>Green</td></tr>
</table>
""";
HtmlConversionDocument source = HtmlConversionDocument.Parse(html);
byte[] pdf = source.ToPdf();
source.SaveAsPdf("quarterly-update.pdf");
Naming is consistent across the direct output APIs:
ToPdf()returns encoded bytes.ToPdfDocument()returns the first-party PDF model.ToPdfDocumentResult()returns the PDF model plus diagnostics.ExportImage()andExportImages()return image output, dimensions, and diagnostics.SaveAsPdf(path)andSaveAsPdf(stream)write to a destination.- Async counterparts use the same names with
Asyncappended.
One options shape for PDF, PNG, and SVG
HtmlPdfSaveOptions derives from HtmlRenderOptions, so one configured instance can drive all three direct outputs.
using OfficeIMO.Drawing;
using OfficeIMO.Html;
using OfficeIMO.Html.Pdf;
var options = new HtmlPdfSaveOptions {
PageSize = OfficePageSizes.A4,
Margins = HtmlRenderMargins.All(32),
DefaultFontFamily = "Arial",
BackgroundColor = OfficeColor.White,
Scale = 1.5
};
HtmlConversionDocument source = HtmlConversionDocument.Parse(html);
byte[] pdf = source.ToPdf(options);
byte[] png = source.ToPng(options);
string svg = source.ToSvg(options);
PDF always uses paged layout. PNG and SVG honor the selected render mode and page index.
Diagnostics and external resources
Options are reusable configuration and are not mutated with operation results. Request a result when diagnostics matter.
var options = new HtmlPdfSaveOptions {
ResourceResolver = (request, cancellationToken) =>
Task.FromResult<HtmlResolvedResource?>(null)
};
HtmlConversionDocument source = HtmlConversionDocument.Parse(html);
var result = await source.ToPdfDocumentResultAsync(options);
var pngResult = await source.ExportImageAsync(OfficeImageExportFormat.Png, options);
var svgResult = await source.ExportImageAsync(OfficeImageExportFormat.Svg, options);
await result.SaveAsync("report.pdf");
foreach (var warning in result.Report.Warnings) {
Console.WriteLine($"{warning.Code}: {warning.Message}");
}
foreach (var diagnostic in pngResult.Diagnostics) {
Console.WriteLine($"{diagnostic.Code}: {diagnostic.Message}");
}
foreach (var diagnostic in svgResult.Diagnostics) {
Console.WriteLine($"{diagnostic.Code}: {diagnostic.Message}");
}
Resource resolution is opt-in and controlled by HtmlUrlPolicy, timeouts, byte limits, count limits, and stylesheet-depth limits inherited from HtmlRenderOptions.
Explicit document projections
Direct rendering is the normal HTML-to-PDF path. If the desired target is an editable Word document or a Markdown AST, request that target explicitly and then use its PDF converter:
using OfficeIMO.Markdown.Html;
using OfficeIMO.Markdown.Pdf;
using OfficeIMO.Word.Html;
using OfficeIMO.Word.Pdf;
HtmlConversionDocument source = HtmlConversionDocument.Parse(html);
byte[] markdownPdf = source.ToMarkdownDocument().ToPdf();
using var word = source.ToWordDocument();
byte[] wordPdf = word.ToPdf();
Those adapters remain separate packages and are not dependencies of OfficeIMO.Html.Pdf.
PDF to HTML
using OfficeIMO.Html.Pdf;
string semantic = PdfHtmlConverterExtensions.ToHtml("quarterly-update.pdf", new PdfHtmlSaveOptions {
Profile = PdfHtmlProfile.Semantic
});
PdfHtmlConverterExtensions.SaveAsHtml("quarterly-update.pdf", "quarterly-review.html", new PdfHtmlSaveOptions {
Profile = PdfHtmlProfile.PositionedReview,
IncludeLinkAnnotations = true,
IncludeFormWidgets = true,
ImageExportMode = PdfHtmlImageExportMode.EmbeddedDataUri
});
PDF-to-HTML profiles describe how an existing PDF is projected to HTML. They are unrelated to HTML-to-PDF, which has one direct rendering path.
Targets and license
- Targets:
netstandard2.0,net8.0,net10.0. - License: MIT.
- Repository: EvotecIT/OfficeIMO
Dependency footprint
- External: None beyond AngleSharp/AngleSharp.Css already isolated in
OfficeIMO.Html; no browser process or native HTML renderer. - OfficeIMO:
OfficeIMO.Html,OfficeIMO.Pdf, andOfficeIMO.Drawingown layout, rendering, reverse projection, and reports.
See the complete OfficeIMO package map for related formats and conversion paths.
| Product | Versions 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 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 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. |
| .NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
| .NET Standard | netstandard2.0 is compatible. netstandard2.1 was computed. |
| .NET Framework | net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 is compatible. net48 was computed. net481 was computed. |
| MonoAndroid | monoandroid was computed. |
| MonoMac | monomac was computed. |
| MonoTouch | monotouch was computed. |
| Tizen | tizen40 was computed. tizen60 was computed. |
| Xamarin.iOS | xamarinios was computed. |
| Xamarin.Mac | xamarinmac was computed. |
| Xamarin.TVOS | xamarintvos was computed. |
| Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETFramework 4.7.2
- OfficeIMO.Drawing (>= 2.0.1)
- OfficeIMO.Html (>= 2.0.1)
- OfficeIMO.Pdf (>= 2.0.1)
-
.NETStandard 2.0
- OfficeIMO.Drawing (>= 2.0.1)
- OfficeIMO.Html (>= 2.0.1)
- OfficeIMO.Pdf (>= 2.0.1)
-
net10.0
- OfficeIMO.Drawing (>= 2.0.1)
- OfficeIMO.Html (>= 2.0.1)
- OfficeIMO.Pdf (>= 2.0.1)
-
net8.0
- OfficeIMO.Drawing (>= 2.0.1)
- OfficeIMO.Html (>= 2.0.1)
- OfficeIMO.Pdf (>= 2.0.1)
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 |
|---|---|---|
| 2.0.1 | 194 | 7/14/2026 |
| 2.0.0 | 47 | 7/14/2026 |
| 1.0.13 | 202 | 7/9/2026 |
| 1.0.12 | 268 | 7/8/2026 |
| 1.0.11 | 424 | 7/5/2026 |
| 1.0.10 | 194 | 7/4/2026 |
| 1.0.9 | 208 | 6/27/2026 |
| 1.0.8 | 106 | 6/27/2026 |
| 1.0.7 | 363 | 6/24/2026 |
| 1.0.6 | 153 | 6/23/2026 |
| 1.0.5 | 273 | 6/21/2026 |
| 1.0.4 | 113 | 6/16/2026 |
| 1.0.3 | 294 | 6/16/2026 |
| 1.0.2 | 109 | 6/15/2026 |
| 1.0.1 | 226 | 6/13/2026 |
| 1.0.0 | 217 | 6/12/2026 |