API reference
Every public type and member of the WeblitzPdf namespace (assembly WeblitzPdf), as the engine documents them: each member's signature, its default, the values it takes, and where a page of this documentation shows it rendered. Puppeteer's name for an option is given as a note, for those who print with it today.
HtmlToPdf static class
HTML to PDF as Chrome prints it: the page's HTML and CSS laid out, its scripts run once before printing, its pages written as a PDF. Thread-safe: documents render at once on as many threads as the caller uses.
Render
static methodpublic static HtmlPdfResult Render(string html, HtmlPdfOptions? options = null)
The PDF of html. Relative addresses resolve against HtmlPdfOptions.BaseUrl: a folder's (file:) files are read from that folder only, a web address's through the network the options allow; without one, nothing is fetched.
- Parameters
html: The document's HTML.options: How to print it; null: HtmlPdfOptions.Default.
- Throws
System.ArgumentNullException:htmlis null.System.ArgumentOutOfRangeException: The options' HtmlPdfOptions.Scale is outside 0.1 to 2, or HtmlPdfOptions.ScrollStepWait outside 0 to 60 seconds.System.ArgumentException: The options contradict themselves: HtmlPdfOptions.PdfA with passwords, an empty HtmlPdfOptions.Format without HtmlPdfOptions.Width and HtmlPdfOptions.Height, an empty HtmlPdfOptions.ScrollTo, a HtmlPdfOptions.Region whose From is empty or whose Height is no length, a network header the fetcher writes itself (Host, Cookie...) or holding a line break, a cookie or credentials that cannot be sent (HtmlNetwork.Headers, HtmlNetwork.Cookies, HtmlNetwork.Credentials).HtmlRenderException: No PDF could be made at all (a stage of the engine failed); a page's own errors are notes, never exceptions.
- Puppeteer
page.setContent(html) then page.pdf()- Rendered
- Your first PDF: HTML text, Into a stream
RenderFile
static methodpublic static HtmlPdfResult RenderFile(string path, HtmlPdfOptions? options = null)
The PDF of the HTML file at path: its CSS, pictures, fonts and scripts read from its folder (never outside it), web addresses through the network the options allow.
- Throws
System.ArgumentNullException:pathis null.System.IO.IOException: The file cannot be read (System.IO.FileNotFoundExceptionwhen it is not there).System.ArgumentOutOfRangeException: The options' HtmlPdfOptions.Scale is outside 0.1 to 2, or HtmlPdfOptions.ScrollStepWait outside 0 to 60 seconds.System.ArgumentException: The options contradict themselves: HtmlPdfOptions.PdfA with passwords, an empty HtmlPdfOptions.Format without HtmlPdfOptions.Width and HtmlPdfOptions.Height, an empty HtmlPdfOptions.ScrollTo, a HtmlPdfOptions.Region whose From is empty or whose Height is no length, a network header the fetcher writes itself (Host, Cookie...) or holding a line break, a cookie or credentials that cannot be sent (HtmlNetwork.Headers, HtmlNetwork.Cookies, HtmlNetwork.Credentials).HtmlRenderException: No PDF could be made at all (a stage of the engine failed); a page's own errors are notes, never exceptions.
- Puppeteer
page.goto('file://...') then page.pdf()- Rendered
- A file and its folder
RenderUrl
static methodpublic static HtmlPdfResult RenderUrl(Uri url, HtmlPdfOptions? options = null)
The PDF of the page at url, fetched with its resources. The network is the options' (HtmlPdfOptions.Network); when they leave it off, the page's own host is allowed. A page the server answers with an error status (401, 403, 404...) and a page of its own is printed, as Chrome prints it: HtmlPdfResult.HttpStatus and a note with the code documentHttpError tell it apart.
- Throws
System.ArgumentNullException:urlis null.System.ArgumentException:urlis not an absolute http or https address (a file goes to HtmlToPdf.RenderFile), or the options contradict themselves (as for HtmlToPdf.Render).System.ArgumentOutOfRangeException: The options' Scale or ScrollStepWait is out of its range.HtmlRenderException: The page could not be loaded (no answer, refused, or an error status with no page), or no PDF could be made at all.
- Puppeteer
page.goto(url) then page.pdf()- Rendered
- A web address
Render
static methodpublic static HtmlPdfResult Render(string html, Stream output, HtmlPdfOptions? options = null)
The PDF of html written to output (the result's HtmlPdfResult.Pdf is then null).
- Throws
System.ArgumentNullException:htmloroutputis null.System.ArgumentOutOfRangeException: The options' HtmlPdfOptions.Scale is outside 0.1 to 2, or HtmlPdfOptions.ScrollStepWait outside 0 to 60 seconds.System.ArgumentException: The options contradict themselves: HtmlPdfOptions.PdfA with passwords, an empty HtmlPdfOptions.Format without HtmlPdfOptions.Width and HtmlPdfOptions.Height, an empty HtmlPdfOptions.ScrollTo, a HtmlPdfOptions.Region whose From is empty or whose Height is no length, a network header the fetcher writes itself (Host, Cookie...) or holding a line break, a cookie or credentials that cannot be sent (HtmlNetwork.Headers, HtmlNetwork.Cookies, HtmlNetwork.Credentials).HtmlRenderException: No PDF could be made at all (a stage of the engine failed); a page's own errors are notes, never exceptions.
- Puppeteer
page.setContent(html) then page.pdf()- Rendered
- Your first PDF: HTML text, Into a stream
RenderAsync
static methodpublic static Task<HtmlPdfResult> RenderAsync(string html, HtmlPdfOptions? options = null, CancellationToken cancellationToken = default)
HtmlToPdf.Render on the thread pool. A cancellation stops a render that has not started; one under way runs to its end or to its limits (HtmlScripts.Timeout). The task faults with the exceptions HtmlToPdf.Render throws.
RenderFileAsync
static methodpublic static Task<HtmlPdfResult> RenderFileAsync(string path, HtmlPdfOptions? options = null, CancellationToken cancellationToken = default)
HtmlToPdf.RenderFile on the thread pool (cancellation as HtmlToPdf.RenderAsync).
RenderUrlAsync
static methodpublic static Task<HtmlPdfResult> RenderUrlAsync(Uri url, HtmlPdfOptions? options = null, CancellationToken cancellationToken = default)
HtmlToPdf.RenderUrl on the thread pool (cancellation as HtmlToPdf.RenderAsync).
HtmlPdfOptions record
What HtmlToPdf prints and how: Puppeteer's page.pdf() options under their names (the reference tool's defaults: A4, backgrounds printed, the page's @page size preferred), and what a server needs beyond them. A record: with makes a variant.
Default
static propertypublic static HtmlPdfOptions Default { get; }
The defaults.
Format
propertypublic string Format { get; init; }
The paper: Letter, Legal, Tabloid, Ledger, A0 to A6 (A4 by default).
- Default
"A4"- Throws
System.ArgumentException: At render: empty while HtmlPdfOptions.Width or HtmlPdfOptions.Height is null.
- Puppeteer
page.pdf({ format })- Rendered
- Paper size and orientation
Width
propertypublic string? Width { get; init; }
The paper's width as a CSS length ("210mm", "8.5in"); with HtmlPdfOptions.Height, wins over HtmlPdfOptions.Format.
- Default
null- Puppeteer
page.pdf({ width })- Rendered
- Paper size and orientation
Height
propertypublic string? Height { get; init; }
The paper's height as a CSS length.
- Default
null- Puppeteer
page.pdf({ height })- Rendered
- Paper size and orientation
Landscape
propertypublic bool Landscape { get; init; }
The paper turned on its side (its width and height swapped). False by default; the page's @page size wins when HtmlPdfOptions.PreferCssPageSize and it gives an orientation.
- Default
false- Puppeteer
page.pdf({ landscape })- Rendered
- Paper size and orientation
Margin
propertypublic HtmlMargins? Margin { get; init; }
The page's margins; null: the page's @page margins, else Chrome's.
- Default
null- Puppeteer
page.pdf({ margin })- Rendered
- Margins
PreferCssPageSize
propertypublic bool PreferCssPageSize { get; init; }
The page's @page size wins over HtmlPdfOptions.Format (Chrome's preferCSSPageSize).
- Default
true- Puppeteer
page.pdf({ preferCSSPageSize })- Rendered
- The page's own @page size
PrintBackground
propertypublic bool PrintBackground { get; init; }
Background colours and pictures printed.
- Default
true- Puppeteer
page.pdf({ printBackground })- Rendered
- Backgrounds
Scale
propertypublic double Scale { get; init; }
The page's content scaled when printed (Chrome's scale): 0.1 to 2, 1 by default; the paper keeps its size.
- Default
1- Throws
System.ArgumentOutOfRangeException: At render: outside 0.1 to 2.
- Puppeteer
page.pdf({ scale })- Rendered
- Scale
PageRanges
propertypublic string? PageRanges { get; init; }
The pages printed: "1-5, 8, 11-13"; null: every page.
- Default
null- Puppeteer
page.pdf({ pageRanges })- Rendered
- Choosing pages
HeaderTemplate
propertypublic string? HeaderTemplate { get; init; }
The header printed in each page's top margin when HtmlPdfOptions.DisplayHeaderFooter: HTML whose elements of the classes pageNumber, totalPages, title, url and date get those values. It is a document of its own, as in Chrome: its styles are the template's (a template without a font-size prints at 1px, as in Chrome), no scripts run, nothing is fetched, backgrounds need print-color-adjust: exact. Null or empty: Chrome's default header (the date and the title).
- Default
null- Puppeteer
page.pdf({ headerTemplate })- Rendered
- Header and footer templates
BaseUrl
propertypublic Uri? BaseUrl { get; init; }
What relative addresses resolve against for HtmlToPdf.Render.
- Default
null- Rendered
- The network
Scripts
propertypublic HtmlScripts Scripts { get; init; }
The page's scripts and its frames': on, as in Chrome.
- Default
HtmlScripts.Default- Rendered
- Scripts and the virtual clock
Network
propertypublic HtmlNetwork Network { get; init; }
The network: off by default (nothing is fetched but a file's own folder).
- Default
HtmlNetwork.Off- Rendered
- A web address, The network
ScrollTo
propertypublic string? ScrollTo { get; init; }
Scroll the window before printing, as a user would before pressing Print (with Puppeteer, a window.scrollTo in page.evaluate before page.pdf): "top", "bottom", a CSS selector (its first match scrolled into view, its top at the window's top) or a length from the document's top in px ("1200px", "1200"). Null (the default): not scrolled. It happens once the page's scripts have settled, in screen media, before beforeprint: the page's scroll events, scroll positions and IntersectionObserver callbacks see it, and what scripts change is printed. Animations on the root scroll timeline print at their start, scrolled or not, as Chrome prints them. The PDF still holds the whole document from its top, as Chrome's print of a scrolled page does; HtmlPdfOptions.Region prints a part of it. Without scripts, nothing changes.
- Default
null- Throws
System.ArgumentException: At render: empty or white space (null not to scroll).
- Puppeteer
page.evaluate(() => window.scrollTo(...)) before page.pdf()- Rendered
- Scrolling to a section first
ScrollThrough
propertypublic bool ScrollThrough { get; init; }
Scroll the window from the top to the document's end, one window height at a time, before printing: what a page loads as one scrolls (infinite lists, images and charts made when they come into view) is loaded and printed. Each step waits HtmlPdfOptions.ScrollStepWait of the page's virtual time; at most 200 steps. The window then goes to HtmlPdfOptions.ScrollTo, else back to the top.
IntersectionObserver without a scroll option (neither this nor HtmlPdfOptions.ScrollTo): every observed element is reported visible once, wherever it is, so content a page loads as it comes into view (lazy images, charts, list items made by scripts) is loaded and printed, the whole page in the PDF, which is what a PDF is for. Chrome reports only what is in the window, so with Puppeteer such a page prints its first screen unless it is scrolled first. With a scroll option, Weblitz reports real intersections with the window, as Chrome does.
- Default
false- Rendered
- Lists that load as you scroll
ScrollStepWait
propertypublic TimeSpan ScrollStepWait { get; init; }
The virtual time each scroll (HtmlPdfOptions.ScrollTo, each step of HtmlPdfOptions.ScrollThrough) gives the page to react: its timers, animation frames, observers and image loads. 0 to 60 seconds; 0.5 s by default.
- Default
00:00:00.5000000- Throws
System.ArgumentOutOfRangeException: At render: outside 0 to 60 seconds.
- Rendered
- Lists that load as you scroll
Region
propertypublic HtmlPrintRegion? Region { get; init; }
Print only a part of the document (null, the default: all of it): from a start (the window's scroll position, a length or an element) to an optional height; what lies above and below is left out. The part is laid out on pages as a whole document is: @page sizes and margins, page breaks, headers and footers.
- Default
null- Rendered
- Printing a part of the page
UserAgent
propertypublic string? UserAgent { get; init; }
The browser the page sees and the network is told of (Puppeteer's page.setUserAgent(userAgent, userAgentMetadata)): navigator.userAgent, appVersion and the User-Agent header. Null: desktop Chrome 156's on the machine's OS (macOS, Windows or Linux).
- Default
null- Puppeteer
page.setUserAgent(userAgent)- Rendered
- The browser the page sees
UserAgentMetadata
propertypublic HtmlUserAgentMetadata? UserAgentMetadata { get; init; }
What navigator.userAgentData says and the Sec-CH-UA headers send. Null: the machine's Chrome's when HtmlPdfOptions.UserAgent is null, else none (as Chrome, given a User-Agent without metadata).
- Default
null- Puppeteer
page.setUserAgent(userAgent, userAgentMetadata)- Rendered
- The browser the page sees
Title
propertypublic string? Title { get; init; }
The PDF's title (the page's <title> when null) and author.
- Default
null- Rendered
- Title, author and PDF/A
Author
propertypublic string? Author { get; init; }
The PDF's author (the page's <meta name="author"> when null).
- Default
null- Rendered
- Title, author and PDF/A
PdfA
propertypublic bool PdfA { get; init; }
A PDF/A-2b document (archival: fonts embedded, an output intent, XMP metadata). False by default.
- Default
false- Throws
System.ArgumentException: At render: with passwords in HtmlPdfOptions.Security (PDF/A forbids encryption).
- Puppeteer
page.pdf({ tagged }) has no PDF/A- Rendered
- Title, author and PDF/A
Security
propertypublic HtmlPdfSecurity? Security { get; init; }
Passwords and permissions (AES-256); not with HtmlPdfOptions.PdfA.
- Default
null- Rendered
- Passwords and permissions
Compression
propertypublic HtmlPdfCompression Compression { get; init; }
How hard the PDF's streams are deflated: HtmlPdfCompression.Fastest by default, smaller files at the cost of time with HtmlPdfCompression.Default or HtmlPdfCompression.Smallest.
- Default
HtmlPdfCompression.Fastest- Values
-
NoneFastestDefaultSmallest - Rendered
- PDF compression
Locale
propertypublic string Locale { get; init; }
What the page's scripts and Intl see: its language, time zone and clock (fixed: the same PDF every time).
- Default
"en-US"- Rendered
- Locale, time zone and clock
TimeZone
propertypublic string TimeZone { get; init; }
The time zone the page's scripts see (an IANA name: "Europe/Paris", "America/New_York"; "UTC" by default): Date's local time and offset and Intl's formatting, as Chrome with an emulated time zone.
- Default
"UTC"- Puppeteer
page.emulateTimezone(timezoneId)- Rendered
- Locale, time zone and clock
Now
propertypublic DateTimeOffset? Now { get; init; }
The clock the page's scripts start at (Date.now(), new Date()), and the PDF's creation date; then virtual time runs from it. Null: a fixed date (2026-01-01 00:00 UTC), so the same input makes the same PDF.
- Default
null- Rendered
- Locale, time zone and clock
UseInstalledFonts
propertypublic bool UseInstalledFonts { get; init; }
The machine's fonts after the page's own @font-face fonts; false: the bundled faces only.
- Default
true- Rendered
- Installed fonts
Limits
propertypublic HtmlPdfLimits Limits { get; init; }
What a page may ask for: input size, pages, resources.
- Default
HtmlPdfLimits.Default- Rendered
- Limits
ExperimentalWebFeatures
propertypublic bool ExperimentalWebFeatures { get; init; }
Chrome's experimental web platform features that Weblitz has built, on, as Chrome 156 lays them out with its "Experimental Web Platform features" flag (default false: Weblitz prints as stable Chrome does, which ignores them). Among them: grid lanes (display: grid-lanes and inline-grid-lanes, the masonry layout, with grid-lanes-direction, grid-lanes-pack and flow-tolerance), their gap decorations and page and column breaks, text-decoration-inset, text-decoration-skip-spaces, text-transform's full-width and full-size-kana beside a case keyword, the flow-start and flow-end alignment keywords, image symbols in @counter-style. Scripts see them too (CSS.supports, the parsed styles).
- Default
false- Rendered
- Chrome's experimental features
HtmlMargins record
Page margins as CSS lengths ("18mm", "0.5in", "40px"; a bare number is px, as Puppeteer reads it).
HtmlMargins
constructorpublic HtmlMargins(string? Top = null, string? Right = null, string? Bottom = null, string? Left = null)
Page margins as CSS lengths ("18mm", "0.5in", "40px"; a bare number is px, as Puppeteer reads it).
- Parameters
Top: The top margin; null: the page's@pagemargin, else Chrome's (about 1 cm).Right: The right margin; null asTop.Bottom: The bottom margin; null asTop.Left: The left margin; null asTop.
Top
propertypublic string? Top { get; init; }
The top margin; null: the page's @page margin, else Chrome's (about 1 cm).
Right
propertypublic string? Right { get; init; }
The right margin; null as Top.
Bottom
propertypublic string? Bottom { get; init; }
The bottom margin; null as Top.
Left
propertypublic string? Left { get; init; }
The left margin; null as Top.
All
static methodpublic static HtmlMargins All(string length)
The same margin on the four sides.
HtmlPrintRegion record
The part of the document HtmlPdfOptions.Region prints: from HtmlPrintRegion.From to HtmlPrintRegion.Height below it. What lies above the start and below the end is left out; the part is laid out on pages as the whole document is, so a tall part breaks into pages.
FromScroll
static propertypublic static HtmlPrintRegion FromScroll { get; }
From the window's scroll position (HtmlPdfOptions.ScrollTo, or where the page's scripts scrolled it) to the end.
From
propertypublic string From { get; init; }
Where the part starts: "scroll" (the default: the window's scroll position when printing starts), "top", a length from the document's top in px ("1200px", "1200"), or a CSS selector (its first match's top). The print's layout is measured, the page's print styles applied: a selector's top is where the element is on paper.
- Default
"scroll"
Height
propertypublic string? Height { get; init; }
How much of the document is printed from HtmlPrintRegion.From, as a CSS length ("1200px", "20cm", "8in", "600pt"; a bare number is px). Null (the default): to the document's end.
- Default
null- Throws
System.ArgumentException: At render: not a length greater than 0.
Of
static methodpublic static HtmlPrintRegion Of(string from, string? height = null)
From from (see HtmlPrintRegion.From), height tall (see HtmlPrintRegion.Height; null: to the end).
HtmlScripts record
The page's scripts: run once before printing (V8), timers and animations in virtual time. Its frames' documents run theirs with them, those of another origin too (as in Chrome, their windows out of the page's reach); HtmlScripts.Off runs none, a frame's neither.
Default
static propertypublic static HtmlScripts Default { get; }
Scripts on, with the default timeout (30 s of CPU time) and wait (5 s of virtual time).
Off
static propertypublic static HtmlScripts Off { get; }
No script runs, a frame's neither: the HTML and CSS as they are written.
Enabled
propertypublic bool Enabled { get; init; }
Whether the page's scripts run (true by default).
- Default
true- Puppeteer
page.setJavaScriptEnabled(enabled)
Timeout
propertypublic TimeSpan Timeout { get; init; }
The CPU time the scripts may take before they are stopped (the pages printed as they are then).
- Default
TimeSpan.FromSeconds(30)
WaitFor
propertypublic TimeSpan WaitFor { get; init; }
The virtual time timers and animations run for before printing.
- Default
TimeSpan.FromSeconds(5)
HtmlNetwork record
What the render may fetch from the network: off, some hosts, or any public host (never the machine's own addresses unless named).
Off
static propertypublic static HtmlNetwork Off { get; }
Nothing is fetched from the network (the default): a file's own folder is still read.
Any
static propertypublic static HtmlNetwork Any { get; }
Any public host (never the machine's own or private addresses unless named in HtmlNetwork.AllowedHosts).
AllowedHosts
propertypublic IReadOnlyList<string> AllowedHosts { get; init; }
The hosts the render may fetch from: names ("example.com"), wildcards ("*.example.com"), "*" for any public host. Empty: the network is off.
- Default
[]
ResourceTimeout
propertypublic TimeSpan ResourceTimeout { get; init; }
The time one resource may take (15 s by default); what has not arrived is left out, noted.
- Default
TimeSpan.FromSeconds(15)
TotalTimeout
propertypublic TimeSpan TotalTimeout { get; init; }
The time the whole document's resources may take together (60 s by default).
- Default
TimeSpan.FromSeconds(60)
CacheDirectory
propertypublic string? CacheDirectory { get; init; }
A folder where fetched resources are kept between renders (HTTP's caching rules), or none. A render with HtmlNetwork.Headers, HtmlNetwork.Cookies, HtmlNetwork.AcceptCookies or HtmlNetwork.Credentials neither reads nor writes it: what a signed-in render receives is never handed to another render.
- Default
null
Headers
propertypublic IReadOnlyList<HtmlRequestHeader> Headers { get; init; }
Request headers added to the render's fetches (an Authorization: Bearer token, an API key), each sent only to the hosts it names, by default the document's own host: never to a CDN or another site's script unless named. A header is not sent on a redirect to a host it does not name. Host, Content-Length, Cookie (use HtmlNetwork.Cookies) and the other headers the fetcher writes itself are refused.
- Default
[]- Puppeteer
page.setExtraHTTPHeaders(headers)- Rendered
- Pages behind a login
Cookies
propertypublic IReadOnlyList<HtmlCookie> Cookies { get; init; }
Cookies the render starts with, as a browser signed in would have them (a session cookie): sent by the cookie rules (domain, path, Secure, SameSite, expiry) with the document, its frames, style sheets, pictures, fonts, scripts and the page's own fetch() and XMLHttpRequest calls to its origin; the page's scripts read them in document.cookie unless HttpOnly. Setting any keeps the cookies servers set during the render too (HtmlNetwork.AcceptCookies).
- Default
[]- Puppeteer
page.setCookie(...cookies)- Rendered
- Pages behind a login
AcceptCookies
propertypublic bool AcceptCookies { get; init; }
Whether the cookies servers set (Set-Cookie, redirects included) and the page's scripts set are kept for the rest of the render and sent back, as a browser does: a login redirect that sets a session cookie then works. Nothing is kept between renders. True whenever HtmlNetwork.Cookies holds any; false by default.
- Default
false- Rendered
- Pages behind a login
Credentials
propertypublic HtmlCredentials? Credentials { get; init; }
A user name and password answering a host's HTTP authentication challenge (Basic or Digest, after its 401), for the hosts they name, by default the document's own host; never sent unasked, nor to another host.
- Default
null- Puppeteer
page.authenticate(credentials)- Rendered
- Pages behind a login
Allow
static methodpublic static HtmlNetwork Allow(string[] hosts)
These hosts only ("example.com", "*.example.com").
WithHeader
methodpublic HtmlNetwork WithHeader(string name, string value, string[] hosts)
This network with a header added (HtmlNetwork.Headers): for hosts, else the document's own host.
WithBearerToken
methodpublic HtmlNetwork WithBearerToken(string token, string[] hosts)
This network with Authorization: Bearer added: for hosts, else the document's own host.
WithCookie
methodpublic HtmlNetwork WithCookie(HtmlCookie cookie)
This network with a cookie added (HtmlNetwork.Cookies).
HtmlRequestHeader record
A request header a render adds to its fetches (HtmlNetwork.Headers).
HtmlRequestHeader
constructorpublic HtmlRequestHeader(string Name, string Value)
A request header a render adds to its fetches (HtmlNetwork.Headers).
- Parameters
Name: The header's name ("Authorization", "X-Api-Key").Value: Its value ("Bearer eyJ...").
Name
propertypublic string Name { get; init; }
The header's name ("Authorization", "X-Api-Key").
Value
propertypublic string Value { get; init; }
Its value ("Bearer eyJ...").
Hosts
propertypublic IReadOnlyList<string> Hosts { get; init; }
The hosts it is sent to ("api.example.com", "*.example.com"); empty: the document's own host only (a document read from a file has none: name the hosts).
HtmlCookie record
A cookie a render starts with (HtmlNetwork.Cookies), as a browser keeps it.
HtmlCookie
constructorpublic HtmlCookie(string Name, string Value)
A cookie a render starts with (HtmlNetwork.Cookies), as a browser keeps it.
- Parameters
Name: Its name.Value: Its value.
Name
propertypublic string Name { get; init; }
Its name.
Value
propertypublic string Value { get; init; }
Its value.
Domain
propertypublic string? Domain { get; init; }
The domain it goes to with its subdomains ("example.com"); null: the document's own host alone.
Path
propertypublic string Path { get; init; }
The path it goes to with the paths under it ("/" by default).
Secure
propertypublic bool Secure { get; init; }
Sent over https: only (and to the machine's own addresses, as Chrome sends it there).
HttpOnly
propertypublic bool HttpOnly { get; init; }
Hidden from the page's scripts (document.cookie, cookieStore).
SameSite
propertypublic HtmlCookieSameSite SameSite { get; init; }
How it goes with requests from other sites (Lax by default).
- Values
-
LaxStrictNone
Expires
propertypublic DateTimeOffset? Expires { get; init; }
When it expires; null: it lasts the render.
HtmlCookieSameSite enum
How a cookie goes with requests from other sites (its SameSite attribute).
Lax
valueLax = 0
With the site's own requests and the top-level document (browsers' default).
Strict
valueStrict = 1
With the site's own requests only.
HtmlCredentials record
A user name and password answering HTTP authentication (HtmlNetwork.Credentials).
HtmlCredentials
constructorpublic HtmlCredentials(string UserName, string Password)
A user name and password answering HTTP authentication (HtmlNetwork.Credentials).
- Parameters
UserName: The user name.Password: The password.
UserName
propertypublic string UserName { get; init; }
The user name.
Password
propertypublic string Password { get; init; }
The password.
Hosts
propertypublic IReadOnlyList<string> Hosts { get; init; }
The hosts that may be answered ("intranet.example.com", "*.example.com"); empty: the document's own host.
HtmlPdfSecurity record
A PDF's passwords and what a reader may do without the owner's (AES-256).
UserPassword
propertypublic string? UserPassword { get; init; }
The password a reader needs to open the PDF; null: it opens without one.
- Default
null
OwnerPassword
propertypublic string? OwnerPassword { get; init; }
The password that lifts the permissions below; null: none set.
- Default
null
PermitPrinting
propertypublic bool PermitPrinting { get; init; }
Whether a reader may print without the owner's password (true by default).
- Default
true
PermitCopying
propertypublic bool PermitCopying { get; init; }
Whether a reader may copy text and pictures without the owner's password (true by default).
- Default
true
PermitModifying
propertypublic bool PermitModifying { get; init; }
Whether a reader may change the document without the owner's password (true by default).
- Default
true
HtmlPdfCompression enum
How hard the PDF's streams are deflated: the fastest by default, smaller at the cost of speed.
None
valueNone = 0
Streams stored without deflating: the largest files, the fastest writing.
Fastest
valueFastest = 1
zlib's fastest level (1): the default, the fastest writing of a deflated PDF.
Default
valueDefault = 6
zlib's default level (6): smaller files, slower writing.
Smallest
valueSmallest = 9
zlib's best level (9): the smallest files, the slowest writing.
HtmlPdfLimits record
What a page may ask for (an untrusted page is held to these).
Default
static propertypublic static HtmlPdfLimits Default { get; }
The default limits (each below).
MaxInputBytes
propertypublic long MaxInputBytes { get; init; }
The largest document read (50 MB by default): past it the rest is not parsed and the result is not HtmlPdfResult.Completed.
- Default
52,428,800 (50 MB)
MaxPages
propertypublic int MaxPages { get; init; }
The most pages printed (10,000 by default): the document is cut there, not completed.
- Default
10,000
MaxNodes
propertypublic int MaxNodes { get; init; }
The most DOM nodes, the parser's and the scripts' (1,000,000 by default): past it the parse or the scripts stop, not completed.
- Default
1,000,000
MaxResourceBytes
propertypublic long MaxResourceBytes { get; init; }
The largest resource fetched or read (20 MB by default): a larger one is left out, noted.
- Default
20,971,520 (20 MB)
MaxTotalResourceBytes
propertypublic long MaxTotalResourceBytes { get; init; }
The most bytes of resources a document fetches and reads in all (200 MB by default).
- Default
209,715,200 (200 MB)
HtmlUserAgentMetadata record
What navigator.userAgentData says and the Sec-CH-UA headers send (CDP's Emulation.UserAgentMetadata, Puppeteer's userAgentMetadata).
Puppeteer: Protocol.Emulation.UserAgentMetadata
Brands
propertypublic IReadOnlyList<HtmlUserAgentBrand> Brands { get; init; }
The brands with their major versions.
- Default
[]
FullVersionList
propertypublic IReadOnlyList<HtmlUserAgentBrand> FullVersionList { get; init; }
The brands with their full versions.
- Default
[]
FullVersion
propertypublic string? FullVersion { get; init; }
uaFullVersion (deprecated in Chrome; Chrome's own when null).
- Default
null
Platform
propertypublic string Platform { get; init; }
"macOS", "Windows", "Linux", "Android"...
- Default
""
PlatformVersion
propertypublic string PlatformVersion { get; init; }
The platform's version ("15.0.0", "10.0.0"); empty: none said.
- Default
""
Architecture
propertypublic string Architecture { get; init; }
"arm", "x86".
- Default
""
Model
propertypublic string Model { get; init; }
The device model, for a mobile device ("Pixel 9"); empty on desktops.
- Default
""
Mobile
propertypublic bool Mobile { get; init; }
Whether the browser says it is a mobile one (navigator.userAgentData.mobile, Sec-CH-UA-Mobile).
- Default
false
Bitness
propertypublic string Bitness { get; init; }
"64", "32".
- Default
""
Wow64
propertypublic bool Wow64 { get; init; }
Whether a 32-bit browser runs on 64-bit Windows (Sec-CH-UA-WoW64); false elsewhere.
- Default
false
FormFactors
propertypublic IReadOnlyList<string>? FormFactors { get; init; }
"Desktop", "Mobile", "Tablet"...; Chrome's ["Desktop"] when null.
- Default
null
ChromeOnThisMachine
static propertypublic static HtmlUserAgentMetadata ChromeOnThisMachine { get; }
Desktop Chrome 156's on the machine's OS, as the engine says by default.
HtmlUserAgentBrand record
A brand of HtmlUserAgentMetadata: navigator.userAgentData's brands and Sec-CH-UA's.
HtmlUserAgentBrand
constructorpublic HtmlUserAgentBrand(string Brand, string Version)
A brand of HtmlUserAgentMetadata: navigator.userAgentData's brands and Sec-CH-UA's.
- Parameters
Brand: The brand's name ("Google Chrome", "Chromium", "Not:A-Brand").Version: Its version: the major one in HtmlUserAgentMetadata.Brands ("156"), the full one in HtmlUserAgentMetadata.FullVersionList ("156.0.8078.47").
Brand
propertypublic string Brand { get; init; }
The brand's name ("Google Chrome", "Chromium", "Not:A-Brand").
Version
propertypublic string Version { get; init; }
Its version: the major one in HtmlUserAgentMetadata.Brands ("156"), the full one in HtmlUserAgentMetadata.FullVersionList ("156.0.8078.47").
HtmlPdfResult class
A printed document: its PDF, its pages, and what the engine noted.
public byte[]? Pdf { get; }
The document; null when it was written to a stream.
PageCount
propertypublic int PageCount { get; }
The pages printed (after page ranges chose some).
Notes
propertypublic IReadOnlyList<HtmlPdfNote> Notes { get; }
What was left out or could not be drawn: a font missing, a resource refused, a script that threw, content shrunk to fit. A page's own errors are notes, never exceptions, as a browser goes on.
- Rendered
- Notes: what could not be done
Completed
propertypublic bool Completed { get; }
False when a limit or the script timeout stopped the render (the pages printed so far are the PDF).
- Rendered
- Limits
Elapsed
propertypublic TimeSpan Elapsed { get; }
How long the render took, from the call to the PDF written.
HttpStatus
propertypublic int? HttpStatus { get; }
The HTTP status the server answered for the document, when it was fetched by its URL (HtmlToPdf.RenderUrl): a success (200), or an error (401, 403, 404...) whose page the server sent and which was printed, as Chrome prints it (a note with the code documentHttpError says so). Null for HTML given as text or read from a file.
HtmlPdfNote record
One thing the engine noted about the document.
HtmlPdfNote
constructorpublic HtmlPdfNote(string Code, HtmlPdfNoteSeverity Severity, string Message, string? Element)
One thing the engine noted about the document.
- Parameters
Code: What kind of note: a stable word ("missingGlyph", "resourceFailed", "limitReached", "scriptError", "notImplemented"...) to sort or filter by.Severity: How much it matters to the PDF.Message: What happened, in plain words.Element: Where, when the note is about one element: its path from the root element, CSS-like (the tag, "#id", the first ".class", ":nth-of-type(n)" among siblings of its name, joined by ">": "html>body>div.card:nth-of-type(2)"); null for the document as a whole.
Code
propertypublic string Code { get; init; }
What kind of note: a stable word ("missingGlyph", "resourceFailed", "limitReached", "scriptError", "notImplemented"...) to sort or filter by.
Severity
propertypublic HtmlPdfNoteSeverity Severity { get; init; }
How much it matters to the PDF.
- Values
-
InfoWarningError
Message
propertypublic string Message { get; init; }
What happened, in plain words.
Element
propertypublic string? Element { get; init; }
Where, when the note is about one element: its path from the root element, CSS-like (the tag, "#id", the first ".class", ":nth-of-type(n)" among siblings of its name, joined by ">": "html>body>div.card:nth-of-type(2)"); null for the document as a whole.
HtmlPdfNoteSeverity enum
How much a note matters to the PDF.
Info
valueInfo = 0
For information: the PDF is as Chrome's would be (a setting ignored as Chrome ignores it, content shrunk to fit).
Warning
valueWarning = 1
Something is missing or differs (a resource not loaded, a glyph a font lacks, a limit reached).
Error
valueError = 2
A part could not be made (a script that threw, a stage that failed).
HtmlRenderException class
No PDF could be made at all (the input over its limit, a stage that failed).
HtmlRenderException
constructorpublic HtmlRenderException(string message)
The exception with what went wrong.
- Parameters
message: Why no PDF could be made, with the engine's error notes.
License static class
Your SSRS2 licence key, which covers Weblitz: the same as Ssrs2.License, under Weblitz's name. Without a key, every page carries a trial watermark.
IsActive
static propertypublic static bool IsActive { get; }
Whether a valid licence is active.
LicensedTo
static propertypublic static string? LicensedTo { get; }
The licensed company, or null when not licensed.
ExpiryDate
static propertypublic static DateTime? ExpiryDate { get; }
The licence's expiry date, or null when not licensed.
UpdatesUntil
static propertypublic static DateTime? UpdatesUntil { get; }
The last release date a licence covers for good, or null (not licensed, or a key that simply expires).
Tier
static propertypublic static string? Tier { get; }
The licence's tier, or null when not licensed.
Features
static propertypublic static IReadOnlyList<string> Features { get; }
The features the active licence names.
Activate
static methodpublic static void Activate(string licenseKey)
Activates the licence key (an SSRS2-... key). Call it once at application startup.
- Throws
SSRS2.Licensing.LicenseException: The key is invalid or has expired.
TryActivate
static methodpublic static bool TryActivate(string licenseKey, out string error)
Activates the licence key without throwing: false and the reason when it is refused.
TryRead
static methodpublic static bool TryRead(string licenseKey, out LicenseInfo? info, out string error)
Reads a licence key without activating it: whether it is genuine and has not expired, and what it says.
HasFeature
static methodpublic static bool HasFeature(string feature)
Whether the active licence names feature.