Meziantou.Framework.WebPlatform.PdfRendering
1.0.1
Prefix Reserved
dotnet add package Meziantou.Framework.WebPlatform.PdfRendering --version 1.0.1
NuGet\Install-Package Meziantou.Framework.WebPlatform.PdfRendering -Version 1.0.1
<PackageReference Include="Meziantou.Framework.WebPlatform.PdfRendering" Version="1.0.1" />
<PackageVersion Include="Meziantou.Framework.WebPlatform.PdfRendering" Version="1.0.1" />
<PackageReference Include="Meziantou.Framework.WebPlatform.PdfRendering" />
paket add Meziantou.Framework.WebPlatform.PdfRendering --version 1.0.1
#r "nuget: Meziantou.Framework.WebPlatform.PdfRendering, 1.0.1"
#:package Meziantou.Framework.WebPlatform.PdfRendering@1.0.1
#addin nuget:?package=Meziantou.Framework.WebPlatform.PdfRendering&version=1.0.1
#tool nuget:?package=Meziantou.Framework.WebPlatform.PdfRendering&version=1.0.1
Meziantou.Framework.WebPlatform.PdfRendering
Prints the documents of Meziantou.Framework.WebPlatform to PDF with
Meziantou.Framework.Pdf: the document is laid out with the print media type and
paginated (@page rules, page breaks, page-margin boxes), and each page becomes a page of vector graphics and text.
// The rendering backend keeps and decodes the images, and rasterizes what PDF cannot draw
using var context = new BrowsingContext(new BrowsingContextOptions { RenderingBackend = new ImagingRenderingBackend() });
context.Navigate("https://example.com/", _ => """
<!DOCTYPE html>
<html lang="en">
<title>Monthly report</title>
<style>@page { size: A4; margin: 2cm }</style>
<h1>Monthly report</h1>
<p>See the <a href="https://example.com/details">details</a>.</p>
""");
context.EventLoop.RunUntilIdle();
// A tagged PDF document (PDF/UA-1): text, links, bookmarks and the structure of the document
var pdf = context.PrintToPdf(options: new PdfPrintOptions { PdfUAConformance = PdfUAConformance.PdfUA1 });
var bytes = pdf.ToByteArray();
- The text is shown with the font files the layout used, embedded as subsets, at the positions the layout computed: it can be selected, searched and extracted.
- The images are embedded (the JPEG images as they are). The browsing context needs a
RenderingBackend, such as theImagingRenderingBackendof Meziantou.Framework.WebPlatform.Imaging, to keep the bytes of the images. - The links are link annotations (a fragment of the document is a destination in the PDF document), the headings are the outline (bookmarks), and the title, language, author, description and keywords of the document are its metadata.
- The document is a tagged PDF: its structure tree is made from the elements of the document (headings, paragraphs, lists,
tables, figures with their alternate text, links), and the decorations are artifacts. Set
PdfUAConformanceandPdfAConformanceto write PDF/UA-1 and PDF/A documents. - What PDF cannot draw is drawn as an image (
RasterizationScalepixels per CSS px): the blurred shadows, the filters, the masks and the compositing operators other than source-over, the 3D transforms, the conic gradients and the color glyphs.
See rendering.md.
| 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. net11.0 is compatible. |
-
net10.0
- Meziantou.Framework.Pdf (>= 1.0.1)
- Meziantou.Framework.WebPlatform (= 1.0.3)
- Meziantou.Framework.WebPlatform.Imaging (>= 1.0.2)
-
net11.0
- Meziantou.Framework.Pdf (>= 1.0.1)
- Meziantou.Framework.WebPlatform (= 1.0.3)
- Meziantou.Framework.WebPlatform.Imaging (>= 1.0.2)
NuGet packages (1)
Showing the top 1 NuGet packages that depend on Meziantou.Framework.WebPlatform.PdfRendering:
| Package | Downloads |
|---|---|
|
Meziantou.Framework.WebPlatform.Playwright
A Playwright server for Meziantou.Framework.WebPlatform: the Playwright clients (.NET, Node.js, Python, Java) connect to it with BrowserType.ConnectAsync and automate the managed browser engine (navigation, locators, actions, assertions, screenshots, network interception). |
GitHub repositories
This package is not used by any popular GitHub repositories.