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.DiagnosticsandPdfHtmlPageAnalysis.DiagnosticsholdPdfHtmlDiagnosticrecords:Severity(Info,WarningorError, OnePDF'sPdfSeverity),Source,PageIndex(zero-based, -1 for the whole document),CodeandMessage. On the command line,-vprints them to standard error and the summary line counts the warnings and errors. - HTML to PDF.
HtmlToPdfResult.DiagnosticsholdsHtmlToPdfDiagnosticrecords:Severity(InfoorWarning),CodeandMessage.
Codes are stable identifiers; messages are for people and may change.
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.
| Code | Severity | Mode | Meaning |
|---|---|---|---|
page-failed | Error | both | A 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-range | Warning | both | PageRanges reaches beyond the document; those pages were ignored. |
link-dropped | Warning (Info for a link to a page outside the conversion) | both | A 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-unplaced | Info | semantic | A link covers no text and was left out. |
image-no-alt | Info | semantic | An image has no description in the PDF and is written with empty alternative text. |
image-skipped | Info | semantic | An image that cannot be shown as a picture (no decoder, or an unsupported colour space) was left out. |
image-failed | Warning | semantic | An image could not be read and was left out. |
image-too-large | Warning | semantic | An image with more pixels than MaxRasterPixels was left out. |
image-unusable | Warning | fixed | An image has no usable data and was left out. |
image-limit | Warning | fixed | An image was left out because a decoding or size limit applies to it. |
asset-limit | Warning | both | An image, web font or page picture was left out because the page reached MaxAssetsPerPage. |
assets-limit | Warning | semantic | A picture of a figure or image was left out because the page reached MaxAssetsPerPage. |
element-limit | Warning | fixed | The page has more drawing operations than one page may write; the rest were left out. |
raster-fallback | Info (Warning when the whole page is a picture) | fixed, semantic figures | Elements 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-reduced | Info | both | The page picture was drawn at a lower resolution than RasterDpi to stay within MaxRasterPixels. |
raster-limit | Warning | fixed | A 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-failed | Error | both | The 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-unmatched | Info | fixed | The page's glyphs could not be matched to its drawing, so its text is placed word by word. |
overprint | Info | fixed | Overprint is not simulated: content is painted as if it knocked out what is below, as the reference render does. Once per page. |
pattern-extgstate | Info | fixed | A shading pattern's graphics state (/ExtGState) is not applied. Once per page. |
knockout-group | Info | fixed | A knockout group inside a soft mask or another frame is drawn as an ordinary group. Once per page. |
table-rules-limit | Info | semantic | The page has too many rules to look for ruled tables; tables are found from the text. |
table-rules-unavailable | Warning | semantic | The page's drawing could not be read, so tables are found from the text alone. |
OCR codes (RecursiveAI.OnePdf.Html.Ocr)
| Code | Severity | Meaning |
|---|---|---|
ocr-page | Info | A page was recognised: the number of words, the resolution, and the rule that decided. |
ocr-dpi-reduced | Info | The page was drawn at a lower resolution than RenderDpi to stay within MaxPixels. |
ocr-empty | Warning | Recognition found no text; the PDF's own text was kept. |
ocr-language-unsupported | Warning | The 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-large | Error | The page is too large to draw for recognition within the pixel limit; its own text was kept. |
ocr-render-failed | Error | The page could not be drawn for recognition; its own text was kept. |
ocr-failed | Error | Recognition 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
| Code | Severity | Meaning |
|---|---|---|
resource-refused | Warning | A 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-missing | Warning | A file could not be read, or a network resource did not answer. |
resource-limit | Warning | A resource, or the count or total size of resources, passed a limit in HtmlResourceLimits. The rest are skipped. |
render-... | Warning | The 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)
| Bound | Default | When it is passed |
|---|---|---|
MaxInputBytes | 1 GiB | PdfHtmlLimitException when the input is opened. |
MaxOutputBytesPerPage | 256 MiB | The page is written empty with page-failed. |
MaxAssetsPerPage | 4,096 | Further images and fonts are left out (asset-limit, assets-limit). |
MaxRasterPixels | 2^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.Default | OnePDF'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 rules | internal | table-rules-limit. |
| Drawing operations per page (fixed layout) | internal | element-limit. |
OCR MaxPixels | 40 million | The page is drawn at a lower resolution. |
HTML to PDF (HtmlToPdfOptions)
| Bound | Default | When it is passed |
|---|---|---|
Limits.MaxInputBytes | 64 MiB | HtmlToPdfFailure.Input. |
Limits.MaxResourceBytes | 32 MiB per resource | The resource is skipped (resource-limit). |
Limits.MaxTotalBytes | 256 MiB for all resources | The rest are skipped (resource-limit). |
Limits.MaxResources | 500 | The rest are skipped (resource-limit). |
MaxPages | 100,000 | HtmlToPdfFailure.Limit. |
Outline.MaxEntries | 10,000 | Further headings get no bookmark. |
Network.RequestTimeout, TotalTimeout, MaxRedirects | 15 s, 60 s, 5 | The resource is skipped (resource-missing), or the input URL fails (HtmlToPdfFailure.Network). |
Time is the caller's limit: pass a CancellationToken.