Recursive AI

Diagnostics and limits

All onepdf-html docs

A conversion never fails silently and never stops at the first thing it cannot do. Whatever it repaired, dropped, approximated or reduced is reported as a diagnostic, and the rest of the document is converted.

Reading diagnostics

  • PDF to HTML. PdfHtmlResult.Diagnostics, PdfHtmlConverter.Diagnostics, PdfHtmlPage.Diagnostics and PdfHtmlPageAnalysis.Diagnostics hold PdfHtmlDiagnostic records: Severity (Info, Warning or Error, OnePDF's PdfSeverity), Source, PageIndex (zero-based, -1 for the whole document), Code and Message. On the command line, -v prints them to standard error and the summary line counts the warnings and errors.
  • HTML to PDF. HtmlToPdfResult.Diagnostics holds HtmlToPdfDiagnostic records: Severity (Info or Warning), Code and Message.

Codes are stable identifiers; messages are for people and may change.

C#
using OnePdf;
using OnePdf.Html;
 
PdfHtmlResult result = PdfHtml.Convert("report.pdf", "diagnosed.html");
foreach (PdfHtmlDiagnostic d in result.Diagnostics.Where(static d => d.Severity != PdfSeverity.Info))
{
    string where = d.PageIndex < 0 ? "document" : $"page {d.PageIndex + 1}";
    Console.WriteLine($"{where}: {d.Code}: {d.Message} ({d.Source})");
}

PDF to HTML codes

Source is Converter for every code below. Diagnostics with Source = Pdf come from OnePDF while it reads the file (a repaired cross-reference table, a wrong length, a missing object); their Code is empty and the message names the object number and offset.

CodeSeverityModeMeaning
page-failedErrorbothA page could not be converted (a damaged page, or its output would pass MaxOutputBytesPerPage). It is written as an empty page with data-error="true"; other pages are not affected.
pages-out-of-rangeWarningbothPageRanges reaches beyond the document; those pages were ignored.
link-droppedWarning (Info for a link to a page outside the conversion)bothA link was dropped: it ran JavaScript, used an action other than web, mail or in-document, led outside the document or to a missing page, or its target scheme is not allowed.
link-unplacedInfosemanticA link covers no text and was left out.
image-no-altInfosemanticAn image has no description in the PDF and is written with empty alternative text.
image-skippedInfosemanticAn image that cannot be shown as a picture (no decoder, or an unsupported colour space) was left out.
image-failedWarningsemanticAn image could not be read and was left out.
image-too-largeWarningsemanticAn image with more pixels than MaxRasterPixels was left out.
image-unusableWarningfixedAn image has no usable data and was left out.
image-limitWarningfixedAn image was left out because a decoding or size limit applies to it.
asset-limitWarningbothAn image, web font or page picture was left out because the page reached MaxAssetsPerPage.
assets-limitWarningsemanticA picture of a figure or image was left out because the page reached MaxAssetsPerPage.
element-limitWarningfixedThe page has more drawing operations than one page may write; the rest were left out.
raster-fallbackInfo (Warning when the whole page is a picture)fixed, semantic figuresElements were drawn from the page picture, with the number and the reason (a shading type, a pattern, a knockout group). As a warning: the page's drawing could not be interpreted, so the whole page is a picture.
raster-reducedInfobothThe page picture was drawn at a lower resolution than RasterDpi to stay within MaxRasterPixels.
raster-limitWarningfixedA page asked for more than 256 pieces of the page picture (a tiling pattern whose cells overlap, repeated thousands of times); the rest are left out, with their number.
raster-failedErrorbothThe page picture, or a piece of it, could not be drawn, or the page is not drawn because its strokes would take too long and too much memory (the message says which bound: the segments of all stroked paths, over 1,000,000, or one stroked path of over 100,000 segments); the elements that needed it are left out.
text-unmatchedInfofixedThe page's glyphs could not be matched to its drawing, so its text is placed word by word.
overprintInfofixedOverprint is not simulated: content is painted as if it knocked out what is below, as the reference render does. Once per page.
pattern-extgstateInfofixedA shading pattern's graphics state (/ExtGState) is not applied. Once per page.
knockout-groupInfofixedA knockout group inside a soft mask or another frame is drawn as an ordinary group. Once per page.
table-rules-limitInfosemanticThe page has too many rules to look for ruled tables; tables are found from the text.
table-rules-unavailableWarningsemanticThe page's drawing could not be read, so tables are found from the text alone.

OCR codes (RecursiveAI.OnePdf.Html.Ocr)

CodeSeverityMeaning
ocr-pageInfoA page was recognised: the number of words, the resolution, and the rule that decided.
ocr-dpi-reducedInfoThe page was drawn at a lower resolution than RenderDpi to stay within MaxPixels.
ocr-emptyWarningRecognition found no text; the PDF's own text was kept.
ocr-language-unsupportedWarningThe page needs recognition, but a language in Languages is written in a script that has no recogniser installed (add the matching RecursiveAI.OneOcr.Models.* package, or there is no model for it yet); those lines were left unread and the PDF's own text was kept where recognition found nothing.
ocr-page-too-largeErrorThe page is too large to draw for recognition within the pixel limit; its own text was kept.
ocr-render-failedErrorThe page could not be drawn for recognition; its own text was kept.
ocr-failedErrorRecognition failed; its own text was kept.

Text-layer rules (PdfHtmlTextSources.Assess)

These are the Code of a PdfHtmlTextLayerAssessment, not diagnostics by themselves: text-layer-ok, empty-page, scanned-page, replacement-characters, private-use-characters, mojibake, unreadable-words, implausible-letters and text-off-ink. The guide says what each means.

HTML to PDF codes

CodeSeverityMeaning
resource-refusedWarningA resource was not loaded by rule: outside the input's folder, a scheme that is never fetched, the network is off, a non-public address, or a relative reference with no folder or address to resolve against.
resource-missingWarningA file could not be read, or a network resource did not answer.
resource-limitWarningA resource, or the count or total size of resources, passed a limit in HtmlResourceLimits. The rest are skipped.
render-...WarningThe renderer approximated something, such as drawing a feature as an image. The text after render- names the kind.

Limits

Every bound is checked before the work or allocation it guards, and none follows input depth. Defaults:

PDF to HTML (PdfHtmlOptions)

BoundDefaultWhen it is passed
MaxInputBytes1 GiBPdfHtmlLimitException when the input is opened.
MaxOutputBytesPerPage256 MiBThe page is written empty with page-failed.
MaxAssetsPerPage4,096Further images and fonts are left out (asset-limit, assets-limit).
MaxRasterPixels2^26 (67 million)The picture is drawn at a lower resolution (raster-reduced); an image above it is left out (image-too-large).
Limits (PdfLimits)PdfLimits.DefaultOnePDF's bounds on decoded stream size, expansion ratio, nesting, XObject and pattern recursion, indirect objects, content operators per page, function operations, image pixels and metadata size. An object or page that passes one is skipped with a diagnostic, or fails with OnePDF's PdfLimitException.
Table rulesinternaltable-rules-limit.
Drawing operations per page (fixed layout)internalelement-limit.
OCR MaxPixels40 millionThe page is drawn at a lower resolution.

HTML to PDF (HtmlToPdfOptions)

BoundDefaultWhen it is passed
Limits.MaxInputBytes64 MiBHtmlToPdfFailure.Input.
Limits.MaxResourceBytes32 MiB per resourceThe resource is skipped (resource-limit).
Limits.MaxTotalBytes256 MiB for all resourcesThe rest are skipped (resource-limit).
Limits.MaxResources500The rest are skipped (resource-limit).
MaxPages100,000HtmlToPdfFailure.Limit.
Outline.MaxEntries10,000Further headings get no bookmark.
Network.RequestTimeout, TotalTimeout, MaxRedirects15 s, 60 s, 5The resource is skipped (resource-missing), or the input URL fails (HtmlToPdfFailure.Network).

Time is the caller's limit: pass a CancellationToken.