Rendering enginePDF
The page renderer of @birchui/pdf/render, which the viewer uses — what it draws, how to call it on the main thread or in a worker, how text is read, how it is verified against poppler and Ghostscript, and a support matrix of operators, colour spaces, shadings, fonts and image filters.
@birchui/pdf/render draws PDF pages to a Canvas 2D context and reads their text, outline, layers, structure and
links. It is written in this package: the content stream interpreter, the colour pipeline, the font programs
(TrueType, CFF, Type 1, Type 3), the image decoders (JPEG, CCITT, JBIG2, JPEG 2000) and the rasteriser used in tests
share no code with another renderer. It reuses the package's own parser, stream filters and decryption.
The viewer draws every page with this engine, in a worker by default. The entry is also public, so you can render
pages and read text without the viewer, in the browser, in a worker or in Node. The viewer options that reach the
engine (worker, renderOptions, allowFetch, fetchDocument) are described under
Loading and rendering.
Open a document and draw a page#
import { openRenderDocument } from '@birchui/pdf/render';
const document = await openRenderDocument(bytes, { password: 'reader' });
const page = await document.getPage(1);
const scale = (96 / 72) * devicePixelRatio;
const viewport = page.getViewport({ scale });
canvas.width = Math.ceil(viewport.width);
canvas.height = Math.ceil(viewport.height);
const task = page.render({ canvasContext: canvas.getContext('2d')!, viewport });
await task.promise;
console.info(task.warnings);getViewport({ scale, rotation, offsetX, offsetY })maps the visible box (CropBox clipped to MediaBox) to pixels.RotateandUserUnitare applied. A negative offset with a small canvas renders one tile of a page.render()returns a task withpromise,cancel()andwarnings. Passsignalto cancel with anAbortSignal. A cancelled task rejects with an error namedRenderingCancelledException.- On the main thread the interpreter yields to the event loop every
timeSlicemilliseconds (10 by default). backgroundis a CSS colour painted first;'transparent'paints nothing.annotationMode0 leaves annotations out, 1 draws every normal appearance stream, 2 leaves out form widgets. An annotation that has no appearance stream is drawn from its own entries (colour, border, geometry, text) with the same code that writes appearances on save, under the same flags: hidden and no-view annotations are skipped, and a print render draws only printable ones. Hidden, no-view and (forintent: 'print') non-print annotations are skipped.intent: 'print'selects the print state of layers and the print flag of annotations.pixelAlignment: falseswitches pixel alignment off for one render. It is on by default and works in worker mode too.
Every other read is a method on the document or the page:
| Call | Result |
|---|---|
document.numPages |
Page count |
page.getText({ includeAnnotations, includeSoftMasks, includeHiddenLayers }) |
Plain text from the package's text extractor; see Text |
page.getTextContent() |
Positioned items { str, transform, width, height, fontName, dir, hasEOL } and font styles |
page.getTextContent({ includeMarkedContent: true }) |
The same with marked-content boundaries for tagged PDFs |
page.getAnnotations() |
Annotation rectangles, flags, link targets, widget names |
page.getStructTree() |
The structure tree restricted to the page |
document.getOutline() |
Bookmarks with destinations or URLs |
document.getDestination(name) |
An explicit destination for a named one |
document.getPageIndex(ref) |
Page index for a page reference from a destination |
document.getPageLabels() |
Page labels, or null |
document.getMetadata() |
The information dictionary and the XMP packet |
document.getAttachments() |
Embedded files |
document.getOptionalContentConfig({ intent }) |
Layers with getOrder(), getGroup(), setVisibility() |
document.on('renderWarning', fn) |
Unsupported features met on a page |
document.cleanup() / document.destroy() |
Drop caches / release everything |
Text#
One extractor reads text for the viewer's search and selection, for getPageText of the headless engine, for
redaction, for comparison and for page.getText() and page.getTextContent() here.
- Right-to-left text (Arabic, Hebrew) comes back in logical order, the order it is read and typed in. The glyphs of a line are sorted by position and the bidirectional reordering is undone. A ligature gives the characters it stands for, and Arabic and Hebrew presentation forms are returned as their base letters.
/ActualTextof marked content replaces the text of the content it encloses.- The Unicode value of a character code comes from
ToUnicode, then from the glyph name of the encoding (Adobe Glyph List), then from the reversecmapof the embedded font, then from the font's own glyph name.
Three conventions decide what counts as page text. Each has a switch:
| Convention | Default | Render API (getText, getTextContent) |
extractPageText, extractStructuredText |
|---|---|---|---|
| Text of annotation appearance streams and form field widgets | Left out | includeAnnotations: true adds it after the page content |
annotations: true |
| Text drawn inside soft-mask groups | Left out | includeSoftMasks: true |
softMasks: true |
| Text in layers that are switched off in the default configuration | Left out | includeHiddenLayers: true |
hiddenLayers: true |
With includeAnnotations and NeedAppearances set in the AcroForm, a text or choice field contributes its value and
a checked box its caption character.
const text = await page.getText({ includeAnnotations: true });The corpus test compares the text of every page with pdftotext -raw. It removes white space and bidirectional
control characters and uses the conventions of pdftotext: annotations and soft masks are included, because
pdftotext cannot leave them out. A run of right-to-left letters is compared as a set of characters, because
pdftotext -raw writes the words of a right-to-left line in content-stream order and reverses the characters of a
ligature. Logical order itself is checked in packages/pdf/test/render-text-logical.test.ts against the sentences
typed into the corpus generator.
Engine with a document source#
createRenderEngine wraps the calls above in one object that takes a document source (data, url or a range
transport) and decides where the work runs. The viewer uses it.
import { createRenderEngine } from '@birchui/pdf/render';
const engine = createRenderEngine({
worker: () => new Worker(new URL('@birchui/pdf/render-worker', import.meta.url), { type: 'module' }),
fetchDocument: async ({ url, range, headers, signal }) => {
const response = await fetch(url, {
headers: range ? { ...headers, Range: `bytes=${range.begin}-${range.end - 1}` } : headers,
signal,
});
return { bytes: await response.arrayBuffer() };
},
});
const document = await engine.getDocument({ url: '/files/annual-report.pdf' }).promise;
console.info(engine.mode);| Option | Default | Meaning |
|---|---|---|
worker |
none | A worker running the @birchui/pdf/render-worker entry, or a function that returns one. Without it the work runs on the calling thread. A worker made by the function is terminated by destroy(); one you pass in stays yours |
onWorkerFallback |
Called once when the worker cannot be constructed or started. The engine continues on the calling thread | |
standardFonts |
true |
Draw fonts that are not embedded from the outlines of @birchui/pdf/render-fonts, loaded the first time a page needs them. false leaves that text to canvas fonts; a function supplies another provider (calling thread only) |
predefinedCMaps |
true |
Read fonts encoded with a predefined CJK CMap through the tables of @birchui/pdf/render-cmaps. false switches them off; a function supplies the data |
allowFetch |
false |
Let the engine load url sources with the global fetch |
fetchDocument |
Your function that loads url sources. It takes precedence over allowFetch |
|
password, onPassword, limits, renderLimits, substituteFont, canvasFactory |
As for openRenderDocument |
The engine makes no network request of its own accord. A url source with neither allowFetch nor fetchDocument
fails with a PdfRenderError whose code is 'fetch-not-allowed'. fetchDocument receives
{ url, range?: { begin, end }, headers?, withCredentials, signal } and resolves with { bytes, total? }. A reply
whose total is larger than the bytes it returned switches the engine to range loading.
Range loading#
openProgressiveDocument takes a loader with length and read(begin, end). The first page can be drawn as soon as
the bytes it needs have arrived, while the remaining bytes are fetched in chunks. Every other page, and every other
call, waits for the whole file.
- A linearized file gives its first-page section at the start of the file.
- For any other file the loader reads the cross-reference data from the end of the file by range requests, then the objects page 1 needs.
In the unit test long-2000.pdf (1,432,471 bytes, 2,000 pages, not linearized) shows page 1 after 276,876 bytes
were requested, 19% of the file.
The loader falls back to a plain download, and shows nothing until it is complete, for files under 256 KB, for encrypted files, and when page 1 needs more than half the file or more than 16 MB.
import { openProgressiveDocument } from '@birchui/pdf/render';
const document = await openProgressiveDocument(
{ length: fileSize, read: (begin, end) => readFromArchive(begin, end) },
{ onProgress: ({ loaded, total }) => showProgress(loaded / total) },
);Worker mode#
createRenderWorker runs parsing, interpretation and rasterisation in a worker you create from the
@birchui/pdf/render-worker entry. Pages are drawn on an OffscreenCanvas there and come back as an ImageBitmap.
The object it returns has the same open() and the documents have the same methods. Without a worker, or in a
browser without OffscreenCanvas, the same calls run on the calling thread and mode says 'main'.
import { createRenderWorker } from '@birchui/pdf/render';
import { standardFontFaces } from '@birchui/pdf/render-fonts';
import { loadPredefinedCMaps } from '@birchui/pdf/render-cmaps';
const worker = new Worker(new URL('@birchui/pdf/render-worker', import.meta.url), { type: 'module' });
const engine = createRenderWorker({
worker,
standardFonts: async () => standardFontFaces(),
predefinedCMaps: loadPredefinedCMaps,
});
const document = await engine.open(bytes);The worker does not import font or CMap data itself. The calling thread loads the substitute fonts and the CMap
table of a character collection the first time a page needs them and sends them to the worker by message.
createRenderEngine and the viewer do this for you; with createRenderWorker you pass the two loaders as above.
Without standardFonts the worker draws fonts that are not embedded with canvas fonts.
A substituteFont provider is a function and cannot be sent to a worker. It runs on the calling thread only. In the
viewer, renderOptions.substituteFont with the default worker selects the main thread; with an explicit worker it
is ignored with a console warning.
Fonts that are not embedded#
Embedded fonts are always drawn from their own outlines. For a font the file does not embed (the standard 14 and others) the engine tries three sources in this order:
substituteFont: the engine asks you for the bytes of a TrueType, OpenType or Type 1 font and draws its outlines.standardFonts: the substitute outlines of@birchui/pdf/render-fonts.- Canvas fonts: each glyph is drawn with
fillTextin a CSS font stack chosen from the font name and descriptor (family, serif or sans, monospace, bold, italic) and scaled horizontally to the width the PDF gives. Glyph shapes then come from the fonts installed on the device.
Advance widths always come from the PDF, so the layout is the document's whichever source draws the glyphs.
@birchui/pdf/render-fonts ships 14 faces:
| Faces | Drawn from | Licence |
|---|---|---|
sans, serif and mono, each in regular, bold, italic and bold italic |
Liberation Sans, Liberation Serif and Liberation Mono, which are metric-compatible with Helvetica and Arial, Times and Courier | SIL Open Font License 1.1 |
symbol |
DejaVu Serif | Bitstream Vera licence; the DejaVu changes are in the public domain |
dingbats |
DejaVu Sans | The same |
The text faces are subsets: Windows-1252 plus the punctuation the standard encodings name (243 of the 245 characters
wanted per face). Hinting and layout tables are removed. The files are generated by
packages/pdf/scripts/build-render-fonts.py, and the licence texts ship in the licenses folder of the package
(LIBERATION-FONTS-OFL.txt, DEJAVU-FONTS-LICENSE.txt).
The pack is loaded the first time a page needs a font that is not embedded; a pre-pass over the page's resources
decides. openRenderDocument takes a loader, createRenderEngine a boolean that is on by default:
import { openRenderDocument } from '@birchui/pdf/render';
const document = await openRenderDocument(bytes, {
standardFonts: async () => (await import('@birchui/pdf/render-fonts')).createStandardFontProvider(),
});The entry also exports standardFontData(face), standardFontFaces(), STANDARD_FONT_FACES and
STANDARD_FONT_SOURCES.
Canvas fonts are still used when the pack is switched off, when it does not have the font, and always for CJK fonts that are not embedded. The substitutes are not the typefaces the document names: text keeps its positions and widths, and the letter shapes differ.
Predefined CMaps#
A composite font may name a predefined CMap, for example 90ms-RKSJ-H or GBK-EUC-H, instead of embedding one.
@birchui/pdf/render-cmaps holds compact tables for them, generated by packages/pdf/scripts/build-render-cmaps.py
from the Adobe CMap resources (BSD-3-Clause; the text ships as licenses/ADOBE-CMAP-RESOURCES-LICENSE.txt).
Each character collection is a module of its own, and only the collection a page needs is loaded, after a pre-pass over the page's fonts:
| Collection | CMaps | CIDs with Unicode | Size in the built module | Gzipped |
|---|---|---|---|---|
| Japan1 | 54 | 23,059 | 100 KB | 76 KB |
| GB1 | 26 | 30,283 | 99 KB | 75 KB |
| CNS1 | 36 | 18,980 | 106 KB | 80 KB |
| Korea1 | 20 | 18,075 | 61 KB | 46 KB |
| Japan2 | 12 | 6,067 | 11 KB | 8 KB |
| KR | 3 | 22,896 | 44 KB | 33 KB |
Covered is every -H and -V CMap of Adobe-Japan1, GB1, CNS1, Korea1, Japan2 and KR, which includes all of
table 118 of ISO 32000-1:
- Japan1:
H,V, the78,Add,Ext,NWP,EUCandRKSJfamilies (83pv,90ms,90msp,90pv),UniJIS,UniJIS2004,UniJISPro,UniJISX0213,UniJISX02132004. - GB1:
GB,GBT,GBK,GBKp,GBK2K,GBpc,GBTpc,UniGB. - CNS1:
B5,B5pc,ETen,ETenms,ETHK,HKdla,HKdlb,HKgccs,HKm314,HKm471,HKscs,CNS1,CNS2,CNS-EUC,UniCNS. - Korea1:
KSC,KSC-EUC,KSC-Johab,KSCms-UHC,KSCms-UHC-HW,KSCpc-EUC,UniKS. - Japan2 (JIS X 0212 supplementary kanji):
Hojo,Hojo-EUC,UniHojo. Its CID to Unicode table is the inverse ofUniHojo-UTF32-H, because the resources hold noAdobe-Japan2-UCS2file. - KR:
UniAKR.
With the table, an embedded font addressed through a predefined CMap is drawn: a CIDFontType2 through its
CIDToGIDMap, a CIDFontType0 through the CFF charset. A font that is not embedded gets its Unicode from ToUnicode,
or else from the CID to Unicode table of the collection, and is drawn with system fonts. -V CMaps set vertical
writing. An embedded CMap stream that refers to a predefined one with usecmap uses the table too.
Not covered:
Hankaku,Hiragana,Katakana,RomanandWP-Symbol;notdefrangeentries: an unmapped code gives CID 0.
A composite font with no ToUnicode whose CIDSystemInfo names one of the six collections gets its Unicode from the
CID to Unicode table of that collection whatever its encoding is: Identity-H, Identity-V, or an embedded CMap
that copies a predefined one in full without usecmap. The table is loaded for such a font as it is for a predefined
CMap name. ToUnicode always wins when it is there.
openRenderDocument takes a loader as predefinedCMaps; createRenderEngine takes a boolean or a loader and is on
by default. The synchronous text extractor of the headless engine cannot load data while it runs, so register the
tables first. The registry is global per thread.
import { loadJapan1CMaps, registerPredefinedCMaps } from '@birchui/pdf/render-cmaps';
registerPredefinedCMaps(await loadJapan1CMaps());loadPredefinedCMaps(collection), loadGb1CMaps, loadCns1CMaps, loadKorea1CMaps, loadJapan2CMaps, loadKrCMaps and
registerAllPredefinedCMaps() are exported as well.
Pixel alignment#
By default the engine places a few things on whole device pixels, which is what keeps rules, table borders and small text crisp at screen resolutions:
- a filled path that is one upright rectangle has its edges rounded to pixels and is at least one pixel wide;
- a solid stroke made of horizontal and vertical segments has its sides rounded to pixels (stroke adjustment);
- a glyph smaller than 64 pixels is placed on a quarter-pixel grid horizontally and a whole pixel vertically;
- an upright image is placed on whole pixels and, when it shrinks, each target pixel is the mean of a block of source pixels.
render({ pixelAlignment: false }) keeps every coordinate exact, which suits output that is scaled again.
Verification#
The corpus in packages/pdf/test/fixtures/render/corpus is built by make-corpus.py: hand-written pages for the
features other producers never emit, plus output from LibreOffice, Chrome, cairo, Ghostscript, pdftops and
pdftocairo round trips, and qpdf variants (object streams, linearized, RC4-40, RC4-128, AES-128, AES-256). It has
69 pages. Each page has a poppler raster at 96 dpi (pdftoppm -cropbox -r 96) and pdftotext -raw output.
packages/pdf/test/render-corpus.test.tsrenders every page in Node through a software rasteriser and compares it with the poppler raster: SSIM over 8 × 8 windows of the grey image and mean absolute difference.e2e/tests/pdf-render-corpus.spec.tsdoes the same in Chrome through a real canvas.packages/pdf/test/render-gaps.test.tscompares single regions of the hand-written pages for transparency groups, ICC profiles and predefined CMaps. The transparency regions are compared with Ghostscript rasters, because poppler does not model knockout and non-isolated groups.e2e/tests/pdf-render-perf.spec.tsmeasures loading and page times for 200 and 2,000 pages.
The targets are a median SSIM of 0.97 and no page below 0.90 other than the differences listed below.
| Run | Median SSIM | Lowest page |
|---|---|---|
| Node, software rasteriser | 0.9976 | 0.9022; no page is below 0.90 |
| Chrome, canvas | 0.9900 | 0.8898, the tiling pattern page, a listed difference |
The text of 69 of 69 pages equals pdftotext -raw under the conventions described under Text. 56 of 69 are
identical character for character.
These figures describe this corpus. They say nothing certain about your files; measure the documents you care about.
Limits#
renderLimits on open caps the work one page may cause: operators executed (20,000,000), form and pattern nesting
(24), graphics state depth (256), pixels of an offscreen surface (64,000,000), bytes of a content stream and of the
image cache. maxRenderMs adds a wall-clock cap and is off by default. The parser limits of the package (stream
size, expansion ratio, image pixels) apply as well. Exceeding a limit rejects the render with a PdfRenderError
whose code is 'limit-exceeded'; an operator that fails is skipped and reported as a warning, and the rest of the
page is still drawn.
Support matrix#
"Yes" means implemented and covered by a corpus page. "Partial" names what is missing. "Untested" means implemented without a corpus page, so do not count on it.
Operators#
| Operators | Status |
|---|---|
q Q cm w J j M d gs |
Yes |
ri i |
Accepted and ignored: rendering intent and flatness have no effect |
m l c v y h re S s f F f* B B* b b* n W W* |
Yes |
BT ET Tc Tw Tz TL Tf Tr Ts Td TD Tm T* Tj TJ ' " |
Yes, render modes 0 to 7 |
CS cs SC SCN sc scn G g RG rg K k |
Yes |
sh |
Yes |
BI ID EI, Do (images, forms) |
Yes |
MP DP BMC BDC EMC |
Yes, including optional content |
BX EX |
Yes |
d0 d1 |
Yes |
ExtGState LW LC LJ ML D Font CA ca BM SMask |
Yes |
ExtGState RI FL SA AIS TK OP op OPM |
Read and ignored: no overprint simulation, stroke adjustment follows pixelAlignment and not SA, alpha-is-shape and text knockout are not modelled |
Colour#
There is no full colour management module. The ICC profiles described below are read and converted to sRGB; every other colour is converted with fixed formulas. Rendering intents and black point compensation are not applied.
| Colour space | Status |
|---|---|
| DeviceGray, DeviceRGB | Yes |
| DeviceCMYK | Yes, by interpolation between process-ink colours; differs slightly from a colour-managed conversion |
| CalGray, CalRGB, Lab | Yes, with a white-point scaling instead of chromatic adaptation |
| ICCBased | Partial. Read: matrix and tone-curve profiles for RGB (gamma, sampled and parametric curves), a tone curve for grey, and the lut8 and lut16 forms of A2B0 for grey, RGB and CMYK, with an XYZ or Lab connection space, converted to sRGB with a Bradford adaptation from D50. A profile that describes sRGB is recognised and skipped. Not read: lutAtoBType (the version 4 lookup tables), named colour profiles and a profile inside a JPEG 2000 file; those fall back to the alternate space |
| Indexed | Yes |
| Separation, DeviceN | Yes, through the tint transform; /None paints nothing; no spot-colour or overprint preview |
| Pattern | Yes |
| Functions type 0, 2, 3, 4 | Yes; type 0 interpolates linearly whatever Order says |
Patterns and shadings#
| Feature | Status |
|---|---|
| Tiling patterns, coloured and uncoloured | Yes. Up to 900 repeats are drawn as vectors, more through a raster cell; TilingType is ignored |
| Shading type 1 (function-based) | Yes |
Shading type 2 (axial), type 3 (radial) with Extend |
Yes |
| Shading type 4, 5 (Gouraud triangles) | Yes, edges are not anti-aliased |
| Shading type 6, 7 (Coons and tensor patches) | Yes, patches are split into at most 24 × 24 cells with bilinear colour |
| Shading patterns on fills, strokes and text | Yes |
Transparency#
| Feature | Status |
|---|---|
Constant alpha CA / ca |
Yes |
| Blend modes, 16 of them | Yes, mapped to the canvas composite operations |
Soft masks, luminosity and alpha, BC, TR |
Yes. Each painted object, text run or form is composited through the mask on its own |
| Isolated groups | Yes, composited against a transparent backdrop |
| Non-isolated groups | Partial: composited against what lies below when something inside uses a blend mode. A non-isolated group that is itself painted with a blend mode is treated as isolated |
| Knockout groups | Partial: each object replaces the earlier ones. Blend modes inside a non-isolated knockout group see a transparent backdrop |
Alpha-is-shape (AIS), text knockout (TK), overprint |
Not modelled |
Image SMask with Matte, Mask (stencil and colour key), stencil masks |
Yes |
Fonts#
| Font | Status |
|---|---|
TrueType (glyf), simple and CIDFontType2 |
Yes, composite glyphs included; hinting is ignored |
| CFF (Type 1C, CIDFontType0C, OpenType) | Yes, Type 2 charstrings with subroutines, CID-keyed fonts |
Type 1 (FontFile) |
Yes: eexec, charstrings, flex, seac; multiple master fonts are not supported |
| Type 3 | Yes, glyph procedures run through the interpreter |
| Type 0 with Identity-H / Identity-V | Yes, including vertical writing with DW2 / W2 |
| Embedded CMap streams | Yes |
| Predefined CMaps | Yes for Identity and every -H and -V CMap of Adobe-Japan1, GB1, CNS1, Korea1, Japan2 and KR, through @birchui/pdf/render-cmaps. Not covered: Hankaku, Hiragana, Katakana, Roman, WP-Symbol and notdefrange entries. See Predefined CMaps |
| Encodings | Standard, MacRoman, WinAnsi, MacExpert, Symbol, ZapfDingbats, Differences |
| Unicode for text extraction | ToUnicode, then the glyph name of the encoding through the Adobe Glyph List, then the reverse cmap of the embedded font, then the font's own glyph name |
| Fonts that are not embedded | Drawn with a font you supply, or with the substitute outlines of @birchui/pdf/render-fonts (Liberation and DejaVu faces, not the named typefaces), or with system fonts. CJK fonts that are not embedded always use system fonts |
| Variable fonts, CFF2, colour fonts | Not supported |
Images#
| Filter or feature | Status |
|---|---|
| Flate, LZW with PNG and TIFF predictors, ASCIIHex, ASCII85, RunLength | Yes |
| DCT | Yes with the package's decoder: baseline and progressive, grey, RGB, CMYK and YCCK. Lossless and arithmetic-coded JPEG are not supported. In browsers a plain JPEG is decoded by the browser with createImageBitmap, off the calling thread: a single DCT filter, 8 bits, grey or YCbCr, DeviceGray, DeviceRGB or an sRGB ICC profile, no mask and no Decode array. It is resized to the drawn size when it is drawn at less than half its size. Everything else, Node, and a file the browser rejects use the package's decoder |
| CCITT Group 3 and Group 4 | Yes |
| JBIG2 | Yes: generic regions (arithmetic templates 0 to 3 and MMR), refinement regions, symbol dictionaries and text regions (arithmetic and Huffman), pattern dictionaries and halftone regions, custom code tables, JBIG2Globals. Not supported: the colour extension and 12-pixel extended templates |
| JPX (JPEG 2000) | Yes: JP2 files and raw codestreams, tiles and tile-parts, all five progression orders, 5/3 and 9/7 wavelets, component transforms, layers, precincts, subsampling, palettes, 1 to 16 bits, the code-block styles of Part 1. Not supported: high-throughput code-blocks (HTJ2K) and Part 2 extensions. An ICC profile in the file is not applied |
Bit depths 1, 2, 4, 8, 16; Decode; inline images; Interpolate |
Yes |
| An image that cannot be decoded | Drawn as a grey box with a cross and reported as an unsupported-image warning |
Document features#
| Feature | Status |
|---|---|
| Encrypted files: RC4-40, RC4-128, AES-128, AES-256 | Yes |
| Object streams, cross-reference streams, linearized files | Yes |
| Annotation appearance streams, appearance states | Yes. An annotation without an appearance stream is drawn from its dictionary: squares, circles, lines, polygons, polylines, ink, text markup, notes, carets, free text and text stamps. Links, popups, widgets and redaction marks without one are not drawn |
| Optional content groups, membership dictionaries, usage for view and print | Yes |
| XFA forms | Not supported. A dynamic XFA form shows its static page content and its AcroForm fields like any other PDF |
Differences from poppler you will see#
- Tiling patterns. poppler draws a pattern cell into a bitmap and tiles that bitmap. On a rotated pattern the
seams are jagged, overlapping cells are cut at the step, and a nested pattern loses its stroke. This engine draws
the cells at their exact pitch. On the pattern page of the corpus the SSIM in Node is 0.9045 between this engine
and poppler, 0.9325 between this engine and Ghostscript, and 0.8877 between poppler and Ghostscript. Rounding the
pitch to whole device pixels was tried and lowered the figure against poppler to 0.8802, so it is not done.
TilingTypeis ignored. - Knockout and non-isolated groups. poppler paints both like an ordinary group. The tests for those regions use Ghostscript rasters.
- Standard fonts that are not embedded. poppler draws them with the fonts fontconfig selects on the machine; this engine draws them with its Liberation substitutes. On the font page of the corpus the SSIM in Node is 0.8046 without any font source, 0.9249 with the bundled pack and 0.9886 when the engine is given the same fonts poppler used on that machine (URW Nimbus). The rest of the difference is the typeface, not the renderer.
UserUnitscales the page here and is ignored bypdftoppm.- An image drawn at exactly its own size is copied pixel for pixel here; poppler filters it.
- CMYK and Lab colours differ by a few levels because neither side uses the same conversion.