CSS properties
202 properties daeepdf 1.2.0 reads from the browser's computed style to draw the PDF, found in its source by the compiler, so none is left out.
Every other property still shapes the PDF through the layout: daeepdf reads where the browser put each box and line, so grid-template-columns or text-indent print as Chrome lays them out without being read here.
Boxes and layout
Chrome lays the template out and daeepdf reads where every box and line landed, so most of these properties reach the PDF through that layout and print as Chrome places them. daeepdf reads them itself only to measure a box, to decide where a page breaks, or to order what paints over what: a box's place and size always come from the layout, never from its width or top. Each entry says what the read is for, and where the result differs from Chrome's print.
displayDecides what is printed at all, how a box paints, and where a page break may fall.
An element with
display: noneprints nothing, and neither does anything inside it: no box, no text, no link, no form field, no image fetched, and no counter reset or incremented.display: contentsmakes no box, so the element's children print but its own background, border,overflow,clip-path,filterandmask-imagedon't apply, as in Chrome.An inline box paints its background, border and shadow on each line it wraps onto, cut as
box-decoration-breaksays. Containment andoverflowdon't apply to an inline box or to a table row, row group or column, and a transform doesn't apply to an inline box; daeepdf ignores them there, as Chrome does.For page breaks, a forced
break-beforeorbreak-aftertakes effect only between block-level boxes in flow (block,list-item,flow-root,table,flex,grid, table rows and row groups), as in Chrome's print, and not on an inline-level box, a float or adisplay: contentselement itself. Flex and grid containers split row by row.The table displays are also read to resolve collapsed borders and to show a row's, row group's or column's background behind its own cells, and
list-itemto draw a marker.import pdf from 'daeepdf' const html = `<style> @font-face { font-family: Inter; src: url('/fonts/inter-var.ttf'); } body { font: 12pt Inter; } .internal { display: none; } </style> <p>Invoice 1042, due 30 June</p> <p class="internal">Note to self: check the rate</p>` const file = await pdf.render(html) // The note isn't in the PDF, not even as hidden text.positionRead to keep out-of-flow boxes out of page breaks, to repeat
fixedboxes on every page, and to order painting.absoluteandfixedboxes are out of the flow, so a page break never moves one: what an absolute box holds past a page's end prints on the next page.relativeandstickyboxes print where the layout puts them.A
fixedbox repeats on every page, in the same place, as Chrome's print repeats it. It is laid out once against the page's content area, sobottom: 0puts it at the foot of every page, and its links and form fields repeat with it. Each copy paints where itsz-indexand tree order put it among that page's content, cut by theclip-path,clipand masks around it. A box with atransform, afilter, containment or a matchingwill-changeholds its fixed descendants instead, and those print once, where they are.A box positioned other than
staticpaints in a layer of its stacking context, byz-index, and afixedorstickybox always makes a stacking context.clipapplies only toabsoluteandfixedboxes. Anoverflowbox clips an absolute descendant only when it, or a box inside it, is that descendant's containing block, as CSS has it.In a collapsed table, a row, row group or cell that
position: relativemoves off the grid paints its background inside its own borders while the table's borders stay on the grid, as Chrome draws it (seetop).import pdf from 'daeepdf' const lines = Array.from({ length: 60 }, (_, i) => `<p>Line ${i + 1}</p>`).join('') const html = `<style> @font-face { font-family: Inter; src: url('/fonts/inter-var.ttf'); } body { font: 12pt/18pt Inter; } .stamp { position: fixed; right: 0; bottom: 0; } </style> <div class="stamp">Confidential</div>${lines}` const file = await pdf.render(html) file.pages // 3 // "Confidential" prints at the foot of all 3 pages.topRead only on a relatively positioned table part, to tell whether it moved off its table's grid.
daeepdf takes every box's place from the layout, so an offset by
topreaches the PDF through it, as Chrome places the box, and daeepdf doesn't read the value for that.It reads it itself on a table row, row group or cell with
position: relative: an offset bytoporleft, or a transform, on the part or a row or group around it, has moved it off the table's grid. In a collapsed table its background then paints inside its own borders, on its cells' padding boxes, and the collapsed borders stay where the grid has them, as Chrome draws them.leftRead only on a relatively positioned table part, as
topis.Like
top, it places a box through the layout, and daeepdf reads it itself only to tell whether a relative offset moved a table part off its grid, where in a collapsed table the part's background paints inside its own borders.floatRead to keep floats out of forced page breaks and out of their ancestors' text decorations.
A float prints where the layout puts it. A
break-beforeorbreak-afteron a float is ignored, as in Chrome's print, since forced breaks fall only between boxes in flow.An ancestor's
text-decorationdoesn't reach into a float, as CSS has it, so an underline on a paragraph doesn't underline a floated note inside it. A floated::first-lettersits in its own box, and daeepdf puts its baseline at an estimate from the middle of that box rather than reading the font's.A float paints after the flow's block backgrounds and before its text, as one, as CSS orders it and Chrome paints it, so where a later block runs under a float, the float is on top (see
z-index).z-indexOrders the painting of positioned boxes, and of flex and grid items, within their stacking context.
A box with
positionother thanstatic, or a flex or grid item with az-index, paints in a layer of the nearest stacking context: negative layers first, under the flow, then the flow, then the other layers byz-index, equal ones in tree order. A positioned box withz-index: autopaints among the layers at 0 and makes no stacking context. Each copy of afixedbox paints where itsz-indexputs it on its page.A
z-indexother thanauto, where it applies, makes the box a stacking context, as doopacitybelow 1,mix-blend-mode,isolation: isolate,clip-path, a transform, paint or layout containment and the matchingwill-changenames. A stacking context with a blending descendant is drawn as an isolated group (seeisolation).Within the flow, daeepdf paints in CSS's order, as Chrome does: every in-flow block's background and border, then the floats, then the text and inline boxes, inline-blocks and flex and grid items each as one, then the outlines, then a stacking context that isn't positioned, with the layers at 0. So where boxes overlap in the flow, such as one pulled up by a negative margin, the earlier box's text lies over the later box's background, and each phase keeps the clips around what it paints.
widthNot read for an HTML box, whose width daeepdf measures from the layout; read for SVG geometry.
A box is as wide as Chrome laid it out, so
width,min-width,max-widthandbox-sizingprint as Chrome sizes the box. The template lays out at the width of the page's content area: the page less itsmargin, or less the template's@pagemargins as Chrome's print reads them.Content that reaches past the page's right edge lays the page out again that wide, up to 1.5 times, and shrinks it onto the paper, as Chrome's print does;
shrinkToFitturns that off. Content a box clips, and aposition: fixedbox, don't count toward that width.daeepdf reads
widthitself on SVG elements: the computedwidthof a<rect>,<image>,<use>,<svg>or<foreignObject>in an inline<svg>goes onto the drawing as its attribute, so a size a stylesheet gives it holds.heightMeasured from the layout for an HTML box; read for SVG geometry and a few repairs at page breaks.
A box is as tall as Chrome laid it out. One taller than the space left on its page runs on to the next, its background and border drawn as one shape the page's edge cuts, or as one box per page with
box-decoration-break: clone.daeepdf reads the value itself in three places: the computed
heightof a<rect>,<image>,<use>,<svg>or<foreignObject>in an inline<svg>, written onto the drawing aswidthis; an empty box of fixed height that a split table's repeated header or footer cuts, which grows by that band so the rest of it starts below; and a pseudo-element whosecontentis an image, which keeps the height you gave it, as Chrome sizes the image by it.vertical-alignRead on table cells, to place a split row's content where Chrome's print places it.
Where inline boxes and text sit on a line comes from the layout, so
vertical-alignthere prints as Chrome lays it out. daeepdf reads the value itself only on table cells.When a page's end splits a row, Chrome's print sets the content of the row's
middleandbottomcells from the top, and a cell spanning into the row from above stays where it is. daeepdf holds those cells' content in the same places as the break grows the row.align-itemsRead on a flex or grid container a page's end splits, to keep aligned items where Chrome's print keeps them.
Items print where the layout put them. When a page break grows a flex line or a grid row, an item placed by alignment, by its own
align-selfor its container'salign-items(center,end,baselineand the rest), keeps its place from the row's start, as Chrome's print keeps it, rather than centering again in the taller row. Items withnormalorstretchgrow with the row.align-selfRead with
align-itemson the items of a flex or grid row a page's end splits.An item's own value wins over its container's
align-items, andautotakes the container's. Seealign-itemsfor what daeepdf does with an item placed by alignment when a page break grows its row.flex-directionRead to choose how a page break moves a flex item: down a column, or by its margin.
To move a box to the next page, daeepdf puts an invisible spacer before it. In a column flex container, a spacer pushes the items after it down, as in a block. In a row flex container or a grid, a spacer would become an item of its own, so the item moves by its top margin instead, and its line or row grows to fit, as Chrome's print grows it. Either way the container breaks row by row rather than moving whole.
margin-topRead to cut or keep a box's top margin at a page break, as Chrome's print does, and to move flex items.
At an unforced break, a top margin that the page's end falls in is cut, and the box starts at the top of the next page, as Chrome's print starts it. After a forced break, such as
break-before: page, the margin is kept, so the box starts that far below the page's top.A box first in its parent, below the parent's top border or padding, takes the parent with it to the next page unless the parent starts its page; with no border, padding or
overflowbetween them, its margin collapses through the parent, as CSS has it.In a flex or grid container, daeepdf moves an item down by adding to its
margin-top, as a spacer there would become an item (seeflex-direction). Boxes a negative margin makes overlap paint in CSS's order (seez-index).margin-rightRead only for a
clip-pathwhose reference box is the margin box.Margins place boxes through the layout and print as Chrome places them. daeepdf reads
margin-rightandmargin-leftitself only to grow the reference box of aclip-pathsuch asinset(0) margin-boxfrom the border box to the margin box.margin-bottomRead to find where a box's margin ends, for page breaks in flex and grid rows and under a table's caption.
A flex or grid item's row runs to the bottom of its margin box, which is how daeepdf tells which items share a row when it breaks the container row by row. In a table with its caption on top, daeepdf moves the header to the next page by the caption's bottom margin, as a spacer there would land below the header.
It also sizes a
clip-pathwith themargin-boxreference box (seemargin-right).margin-leftRead only for a
clip-pathwhose reference box is the margin box.It places the box through the layout, and daeepdf reads it itself only for a
clip-pathwith themargin-boxreference box (seemargin-right).padding-topRead to find a box's padding and content boxes, and whether a page break takes a box with its first child.
daeepdf finds a box's padding box and content box from its border box as Chrome laid it out, inset by the border widths and paddings, the corners curving as
border-radiusgives them. The padding box is whereoverflowand paint containment clip and where background layers are placed by default; the content box is where an<img>,<canvas>or inline<svg>draws and wherebackground-origin: content-boxandbackground-clip: content-boxlie.For page breaks, top padding keeps a first child's top margin from collapsing through its parent, so a page's end falling there takes the parent to the next page with the child (see
margin-top).padding-rightRead to find a box's padding and content boxes, and where an ellipsis goes.
It insets the content box as
padding-topdescribes. The "…" oftext-overflow: ellipsisand of-webkit-line-clampends at the content box's end, inside this padding.padding-bottomRead to find a box's padding and content boxes, and where a page's end may split a table cell.
It insets the content box as
padding-topdescribes, and a-webkit-line-clampbox's last shown line is the last one above it. A page's end can't fall in a table cell's bottom padding or border, so a row whose cut would land there moves to the next page whole, as Chrome's print moves it.padding-leftRead to find a box's padding and content boxes.
It insets the content box as
padding-topdescribes.zoomScales a box and all it holds in a template, as Chrome draws it; on the page around daeepdf's frames, canceled.
daeepdf lays a template out in a frame of its own inside your page. A
zoomon an ancestor of that frame, such as a preview container zoomed to fit, would change the layout in it in some browsers, so daeepdf cancels it on the frame and scales the frame visually instead. The export lays out the same whatever zoom your page has.In a template,
zoomscales a box and everything in it, as Chrome lays it out. Chrome computes lengths unzoomed, so daeepdf scales each one it reads, from font sizes and borders to shadows and transforms, by the element's zoom. A variable font keeps its unzoomed optical size, as in Chrome, and an inline<svg>without aviewBoxis scaled whole.
Visibility, overflow and containment
These decide what prints and what is cut. A clip in the page is a clip in the PDF, and text, links and form fields it hides wholly are left out of the file, as Chrome's print leaves them out. Containment and will-change matter in print mostly for which box holds a position: fixed descendant, which otherwise repeats on every page.
visibilityHides an element's own painting; a descendant set back to
visiblestill prints.With
hiddenorcollapse, the element's background, border, shadow, outline, text, image, form field and link are left out of the PDF, and its text isn't in the file to select or search. Its space stays in the layout, and its counters still count. A descendant withvisibility: visibleprints, as in Chrome.visibility: collapseon a table row prints as Chrome prints it: the row is hidden, takes its content's height rather than a height you set, and has no border spacing after it.On SVG elements the value goes onto the drawing, where a hidden shape doesn't print.
import pdf from 'daeepdf' const html = `<style> @font-face { font-family: Inter; src: url('/fonts/inter-var.ttf'); } body { font: 12pt Inter; } .redacted { visibility: hidden; } .redacted .note { visibility: visible; } </style> <p class="redacted">Account 4421 0098 7731 <span class="note">on file</span></p>` const file = await pdf.render(html) // The text holds "on file" and nothing of the account number.content-visibilityhiddenprints the box without its contents;autoprints everything, contained.content-visibility: hiddenprints the element's own background, border and outline and none of its contents: no text, children, pseudo-elements or list marker, and on an<img>,<svg>or other replaced element no drawing. A link keeps its area. It doesn't apply to a table.A browser skips drawing an
autobox while it's off screen, and Chrome's print draws it all, so daeepdf prints its contents wherever they fall. It keeps the containmentautoimplies: the contents are clipped to the padding box asoverflow: clipclips them, and counters are scoped inside.A closed
<details>prints only its summary, as Chrome hides the rest withcontent-visibility: hiddenon its::details-content, which a stylesheet can override. On the template'shtmlorbody, any value butvisiblekeeps the body's background on the body's own box instead of the whole page, as Chrome does.import pdf from 'daeepdf' const html = `<style> @font-face { font-family: Inter; src: url('/fonts/inter-var.ttf'); } body { font: 12pt Inter; } .answer { content-visibility: hidden; height: 48pt; border: 1pt solid #999; } </style> <p>1. Name three noble gases.</p> <div class="answer">Helium, neon and argon</div>` const file = await pdf.render(html) // The empty bordered box prints; the answer in it doesn't.overflowA box that clips its overflow clips it in the PDF too, and what it hides wholly is left out of the file.
hidden,clip,autoandscrollclip the box's content to its padding box, its corners followingborder-radiusinset by the border, on every page the box spans. A scroll container prints at its first scroll position, without scroll bars. Content a clip hides adds no pages. Underclip,overflow-clip-marginlets the content reach out past the box it names, the padding box by default.Text, links and form fields wholly outside the clip are left out of the PDF, as Chrome's print leaves them out, text glyph by glyph by its ink, so a letter the edge cuts stays in the text and one just past it leaves it.
It doesn't apply to an inline box, a table row, row group or column, or
display: contents, and daeepdf ignores it there, as Chrome does. An absolutely positioned descendant escapes the clip unless the box, or one inside it, is its containing block. On the template'sbody,overflowbelongs to the page, as CSS gives it to the viewport, andhtml's is always visible, so neither clips there, unless either has containment, which keeps the body's overflow its own.Clipping reads
overflow-xandoverflow-y; daeepdf reads the shorthand itself to trim an inline<svg>to its content box where it isn'tvisible, and to tell, at a page break, that a box's first child's margin doesn't collapse through it.import pdf from 'daeepdf' const html = `<style> @font-face { font-family: Inter; src: url('/fonts/inter-var.ttf'); } body { font: 12pt/18pt Inter; } .excerpt { height: 36pt; overflow: hidden; } </style> <div class="excerpt">First line<br>Second line<br>Third line<br>Fourth line</div>` const file = await pdf.render(html) // Two lines fit in 36pt. The fourth is cut, and isn't in the PDF's text.overflow-xRead with
overflow-yto decide whether a box clips, and along which axes.daeepdf clips a box to its padding box when
overflow-xoroverflow-yishidden,clip,autoorscroll. Chrome makes avisibleaxis beside a clipping oneautofor every value butclip, so both axes clip then.clipon one axis alone clips that axis only: withoverflow-x: clipandoverflow-y: visible, the content runs on past the bottom, as in Chrome's print.text-overflow: ellipsistakes effect where the block'soverflow-xclips, and abackground-attachment: locallayer covers what a scroll container scrolls.overflow-yRead with
overflow-xto decide whether a box clips.See
overflow-x:overflow-y: clipwithoverflow-x: visibleclips at the bottom and lets a long line run on past the side, as in Chrome's print.overflow-clip-marginHow far past its box a box under
overflow: cliplets its content reach before the clip cuts it.It names the box the clip starts from,
padding-boxby default,content-boxorborder-box, and a length it grows by on every side, its rounded corners growing with it, as Chrome's print clips. It applies whereoverflow-xoroverflow-yisclip;hidden,autoandscrollclip at the padding box whatever it says, and so does paint containment.clipclip: rect()on an absolutely positioned or fixed box cuts its drawing, as Chrome's print cuts it.The rectangle is
rect(top, right, bottom, left), each edge measured from the top left of the border box, andautoat that edge of the border box. It applies only toposition: absoluteandfixedboxes and is ignored on others, as CSS has it. Unlikeoverflow, it cuts the box's own background, border and shadow too.What it hides wholly is left out of the PDF, text, links and form fields included. A box over several pages has each page's part cut on its own, and each copy of a
fixedbox is cut alike.clip-pathdoes the same with any shape.import pdf from 'daeepdf' const html = `<style> @font-face { font-family: Inter; src: url('/fonts/inter-var.ttf'); } body { font: 12pt Inter; } .tab { position: absolute; clip: rect(0, 60pt, auto, 0); } </style> <div class="tab">INVOICE 2024-117</div>` const file = await pdf.render(html) // Only the first 60pt print: "INVOICE" is in the text, the number's end isn't.containClips, holds fixed descendants and scopes counters, each as CSS containment asks.
paint,strictandcontentclip the box's contents to its padding box, asoverflow: clipdoes, and what that hides wholly is left out of the PDF.layout,paint,strictandcontentmake the box a stacking context and the containing block of itsposition: fixeddescendants, which print once, inside it, instead of repeating on every page, as in Chrome's print.style,strictandcontentscope counters and quotes: what is reset, incremented or opened inside stays inside.sizeandinline-sizechange only the layout.Containment doesn't apply to an inline box or a table row, row group or column, and is ignored there. Any containment on the template's
htmlorbodykeeps the body's background on the body's own box, andpaintthere clips what overflows it, padding included, as on any box.container-typeRead only on the template's
htmlandbody, where a size container keeps the body's background to its box.Container queries are the layout's: what they select prints as Chrome laid it out. daeepdf reads the value itself only on the template's
htmlandbody: when either is asizeorinline-sizecontainer, the page takes onlyhtml's background and the body's stays on the body's box, as Chrome does.A size container doesn't hold its
position: fixeddescendants, which repeat on every page as Chrome's print repeats them.will-changeRead for the stacking contexts and containing blocks it makes, as Chrome makes them.
Chrome gives a box now what the change it names would give it later.
transform,translate,rotate,scale,perspective,transform-styleand theoffsetnames make it the containing block of itsposition: fixeddescendants, except on an inline box;filterandbackdrop-filterdo on any box, andcontainwhere containment applies. A fixed descendant then prints once, inside it, instead of on every page.opacity,isolation,mix-blend-mode,clip-path,mask,filter,transformandperspectivemake it a stacking context, so its positioned descendants paint inside it. Nothing else changes: the property it names takes effect only from its own value.isolationisolatemakes a stacking context, so amix-blend-modeinside blends only with what is inside it.A stacking context with a blending descendant is drawn in the PDF as an isolated transparency group, as CSS Compositing asks: the blend mixes with what the group draws, not with what lies under the group.
isolation: isolatemakes a box such a context without any other effect, as Chrome draws it.With nothing blending inside, it changes only where the positioned descendants paint. On SVG elements the value goes onto the drawing.
Backgrounds
daeepdf draws backgrounds as Chrome prints them with background graphics on: the color as a vector fill, linear and radial gradients as vector shadings and url() images embedded, each layer laid out by background-size, background-position, background-repeat and background-origin and clipped to its background-clip box. It always prints them, and doesn't read print-color-adjust. What a PDF has no operator for is drawn another way: a conic gradient and an SVG image as images, and background-clip: text as a flat color.
background-colorFills the box under its image layers, clipped to the bottom layer's
background-clipbox.The color is a vector fill of the border box by default, under every
background-imagelayer, its corners curved byborder-radius. The last value ofbackground-clip, the bottom layer's, sets the box it fills, and withtextit fills nothing. A translucent color keeps its alpha, as the fill's opacity in the PDF.A box over several pages is filled as one shape the pages cut, or as one per page with
box-decoration-break: clone, and an inline box fills each line it wraps onto. The template'shtmlbackground, else itsbodyone, covers every page, as Chrome prints a document's canvas. A table row's, row group's or column's color shows only behind its own cells.daeepdf always prints backgrounds, as Chrome does with Background graphics checked. An unstyled
<input>,<button>,<select>or<textarea>keeps Chrome's native look, a 1px gray border with 2px corners, until you give it a background or a border.background-imageDraws each layer: gradients as vector shadings,
url()images embedded, conic gradients and SVGs as images.Layers paint last to first, so the first listed is on top, all above the background color and under the border. A linear or radial gradient, repeating or not, is a vector shading, stops with partial alpha included. A conic gradient has no PDF shading and is drawn as an image at 3 pixels per point.
image-set()draws its option of highest resolution, as print wants.A
url()image is fetched once per export. A JPEG goes into the PDF as it is, a PNG as its pixels compressed again, WebP and AVIF decoded by the browser into pixels, and an SVG drawn as an image at 3 pixels per point. A GIF, BMP or TIFF, an image that doesn't load in time, a cross-origin one served without CORS headers, and any other value daeepdf can't draw are skipped with an'image-skipped'warning, and the layers under them still print.An element draws its first 32 layers; past them the rest are skipped with one
'limit-reached'warning per export. Each layer is laid out by its own value ofbackground-size,background-position,background-repeat,background-origin,background-clip,background-attachmentandbackground-blend-mode, a shorter list repeating as CSS repeats it, sobackground: url(a.png), url(b.png); background-repeat: no-repeatrepeats neither.import pdf from 'daeepdf' const gif = 'data:image/gif;base64,R0lGODlhAQABAAAAACw=' const html = `<style> @font-face { font-family: Inter; src: url('/fonts/inter-var.ttf'); } .hero { font: 24pt Inter; height: 120pt; color: white; background-image: url(${gif}), linear-gradient(#1e3a8a, #3b82f6); } </style> <div class="hero">Spring catalog</div>` const file = await pdf.render(html) file.warnings.map((w) => w.code) // ['image-skipped'], for the GIF layer alonebackground-positionPlaces each layer's first tile in its
background-originbox, as Chrome places it.Keywords, lengths and percentages resolve against the origin box less the tile, so
100% 100%puts the tile in the bottom right corner, and the four-value form, such asright 4px bottom 4px, works as Chrome computes it. A repeating layer tiles out from that tile both ways.A
fixedlayer is placed on the page's content area instead (seebackground-attachment), and the template's page background from the first page's top left.background-sizeSizes each layer's tile, as Chrome sizes it.
autotakes an image's natural size, divided by its resolution for animage-set()option, or the whole origin box for a gradient, which has none.coverandcontainscale an image to cover or fit the origin box, keeping its ratio. A length or percentage withautokeeps the ratio, and percentages are of the origin box. An SVG with only aviewBoxtakes its ratio, fitted into the box, and one with neither fills it.A gradient tile is one vector shading the PDF repeats, however small the tile (see
background-repeatfor the limits).background-repeatTiles each layer as Chrome does:
repeat,repeat-x,repeat-y,no-repeat,spaceandround.A repeating layer covers its
background-clipbox with whole tiles from the onebackground-positionplaces, cut at the edges of that box.spacespreads whole tiles edge to edge and doesn't repeat where fewer than two fit.roundscales the tile so a whole number fit, and withautosize on the other axis scales it there too, keeping the image's ratio.Image tiles are drawn one by one up to 2,000 per layer and 100,000 per export; past either, they are drawn in blocks of several tiles, each one image, so the box is still covered. A gradient's tiles are one shading the PDF repeats within the same limits, and past them its tile is drawn as an image and tiled the same way.
background-originSets the box each layer is placed and sized in: the padding box unless you say otherwise.
padding-box,border-boxandcontent-boxare found from the border box Chrome laid out, inset by the border widths and paddings. A layer is cut by itsbackground-clipbox, not by its origin box, so a repeating layer runs on under the border, as in Chrome.It is ignored for a
fixedlayer, laid out on the page's content area, and for the template's page background, which Chrome's print lays out from the page's top left whateverhtml's margin or origin.background-clipClips each layer to its border, padding or content box;
textprints the text in a flat color instead.Each layer is clipped to its own box,
border-boxby default, with the cornersborder-radiusgives, inset for the padding and content boxes. The background color takes the last value, the bottom layer's. An image placed past its clip box is cut at its edge.A PDF can't clip a fill to the shapes of glyphs, so
textis drawn another way. The box paints no fill and no layer clipped to text, only itsbox-shadow, and text with a transparent fill (color: transparent, or-webkit-text-fill-color: transparent, as the gradient-text pattern sets it) paints in one flat color: the first stop of the first gradient layer, else thebackground-color, else black. Aurl()image gives no color. Chrome's print shows the gradient through the glyphs. Text with a color of its own paints in that color, as in Chrome.daeepdf reads
-webkit-background-clipfirst and this one after; Chrome keeps the two as one property.import pdf from 'daeepdf' const html = `<style> @font-face { font-family: Inter; src: url('/fonts/inter-var.ttf'); } h1 { font: 800 36pt Inter; background: linear-gradient(90deg, #7c3aed, #db2777); background-clip: text; color: transparent; } </style> <h1>Annual report</h1>` const file = await pdf.render(html) // The heading prints as text you can select and search.-webkit-background-clipThe prefixed name of
background-clip, which daeepdf reads first; in Chrome the two are one property.Everything
background-clipsays holds for it,textincluded. A stylesheet that sets-webkit-background-clip: textalone for gradient text gets that text in a flat color, asbackground-clip: textdoes.background-attachmentfixedis laid out on the page's content area at the top of each page;localfollows a scroll container's content.scroll, the default, lays a layer out on its box. Afixedlayer is laid out on the viewport of the window daeepdf lays the page out in, which is the page's content area, at the top of every page, and is painted only where the box covers that area there, as Chrome prints it. A box running over several pages shows the layer in the same place on each page where it covers that spot.A
locallayer on a scroll container is laid out on all it scrolls, at its first scroll position, and painted inside its padding box with the content, never under its border, as Chrome paints it. On a box that doesn't scroll,localprints asscroll.On the template's
htmlorbody, the page's background runs on across pages whatever the attachment, as Chrome lays out a document's canvas.background-blend-modeBlends each layer with the layers and color under it, in a group of their own, with the PDF's blend modes.
These blend modes each have a PDF one of the same name:
multiply,screen,overlay,darken,lighten,color-dodge,color-burn,hard-light,soft-light,difference,exclusion,hue,saturation,colorandluminosity. A value without one, such asplus-lighter, draws asnormal.A box whose layers blend draws its background as an isolated group, so they mix with its own color and lower layers only, not with what lies under the box, as CSS Compositing asks and Chrome paints it. The group then takes the element's
opacityandmix-blend-mode. The PDF viewer does the blending.
Borders, outlines and shadows
Borders, outlines and box shadows are vector paths drawn in Chrome's geometry: dashes and dots in its pattern, double and 3D styles in its proportions and shades, corners as border-radius curves them. A border-image is drawn from its source cut into nine slices, each an image. A collapsed table resolves its borders itself and draws one per edge of its grid (see border-collapse).
border-top-widthHow wide the top border is drawn, and how far the padding box sits inside the border box.
Chrome computes it to 0 where the style is
noneorhidden, so only a drawn border has a width. It is drawn inward from the edge of the border box, in the points the layout gives it (1pxis 0.75pt). Adoubleborder narrower than 3px draws solid, as Chrome draws it.It also sets where the padding box starts, which
overflow,background-clip: padding-boxand the defaultbackground-originuse, and how much a rounded corner's inner curve shrinks. In a collapsed table, the widest border meeting at an edge wins (seeborder-collapse). Aborder-imagedraws in place of the border, as wide as this by default.border-right-widthHow wide the right border is drawn, as
border-top-widthdescribes for the top.border-bottom-widthHow wide the bottom border is drawn, as
border-top-widthdescribes for the top.At a page break, the end of a page can't fall in a table cell's bottom border or padding, so a row whose cut would land there moves to the next page whole, as Chrome's print moves it.
border-left-widthHow wide the left border is drawn, as
border-top-widthdescribes for the top.border-top-styleThe top border's style, drawn as Chrome draws it.
solidis a band.dashedanddottedfollow Chrome's pattern, the gaps stretched so each side starts and ends on a dash; dots are square up to 3px wide and round past that.doubleis two lines a third of the width each.groove,ridge,insetandoutsetare drawn in a dark and a light shade of the color, worked out as Chrome works them out.noneandhiddendraw nothing.Sides that share a width, style and color draw as one ring, with no seam at the corners, and sides that differ meet in mitered corners. In a collapsed table,
hiddenwins over every other border at its edge, andinsetandoutsetdraw asridgeandgroove, as CSS 2.1 has it.Chrome draws an unstyled form control's border natively until you give it one of your own, and daeepdf reads the top style to tell (see
background-color).border-right-styleThe right border's style, drawn as
border-top-styledescribes.border-bottom-styleThe bottom border's style, drawn as
border-top-styledescribes.border-left-styleThe left border's style, drawn as
border-top-styledescribes.border-top-colorThe top border's color, its alpha kept as the PDF's opacity.
It arrives as Chrome computes it,
currentColorresolved, and any color syntax Chrome computes,oklch()andcolor-mix()among them, is converted to sRGB. A transparent side draws nothing. Sides of one color fill as one shape, so a translucent border shows no darker corners where its sides meet.border-right-colorThe right border's color, as
border-top-colordescribes.border-bottom-colorThe bottom border's color, as
border-top-colordescribes.border-left-colorThe left border's color, as
border-top-colordescribes.border-radiusRead as written only where a split table's repeated rows show the boxes around the table; the corners come from the longhands.
Chrome computes the shorthand into
border-top-left-radiusand the other three corners, which daeepdf reads to curve every box. It reads the shorthand itself in one place: where a page's end splits a table row and the table repeats its header, the backgrounds of the boxes around the table show under the repeated rows, each with its box's corners.border-top-left-radiusCurves the top left corner of the box's background, border, shadow, outline and clips.
One value is a circle's radius and two,
H V, an ellipse's. A percentage is of the box's width for H and its height for V, so50%makes an ellipse of a box that isn't square. Where the radii along a side add up to more than its length, all of them shrink by one factor until they fit, as CSS has it, soborder-radius: 9999pxmakes a pill.The curve shapes the background color and each layer's clip, both edges of the border, the box shadow, whose curve grows with its spread and blur, the outline, whose curve grows with its offset, and the clip of
overflow, inset by the border. An inline box broken over lines keeps only the corners at its start and end underbox-decoration-break: slice.border-top-right-radiusCurves the top right corner, as
border-top-left-radiusdescribes.border-bottom-right-radiusCurves the bottom right corner, as
border-top-left-radiusdescribes.border-bottom-left-radiusCurves the bottom left corner, as
border-top-left-radiusdescribes.border-image-sourceDraws a border image in place of the border: a
url()image, animage-set()or a gradient, cut into nine slices.The source is drawn on a canvas and cut into nine slices by
border-image-slice, each embedded as a PNG: aurl()image at its natural size in pixels, and a gradient, linear, radial or conic, over the border box at 3 pixels per point, since a gradient has no size of its own.image-set()takes its option of highest resolution.With a source, the CSS border isn't drawn, though its widths still size the border image. A source that doesn't load, a cross-origin image without CORS headers among them, is skipped with an
'image-skipped'warning, and the CSS border draws instead. A collapsed table and its cells take no border image, as in Chrome.The slices count toward the export's raster budget of 64 megapixels, and a source image over 50 megapixels is skipped.
import pdf from 'daeepdf' const html = `<style> @font-face { font-family: Inter; src: url('/fonts/inter-var.ttf'); } .frame { font: 12pt Inter; border: 6pt solid #b91c1c; border-image-source: url('/images/missing-frame.png'); border-image-slice: 30; } </style> <div class="frame">Certificate of completion</div>` const file = await pdf.render(html) file.warnings.map((w) => w.code) // ['image-skipped']border-image-sliceWhere the border image's source is cut into its nine slices.
Numbers are pixels of the source at its natural size, for a gradient CSS pixels over the border box, and percentages are of that size; a slice larger than the source takes all of it. The default,
100%, makes the whole source the four corners. Withoutfillthe middle slice is left out; with it, the middle draws over the background, scaled as the top and left edges are, as CSS has it.border-image-widthHow wide the border image's edge slices are drawn.
A number multiplies the border width on that side, so the default,
1, is the border width. A length is used as it is, a percentage is of the border image area, outset included, andautois the slice's own size. Where two opposite sides add up to more than the area, all four shrink by one factor until they fit, as CSS has it.border-image-outsetHow far the border image reaches past the border box.
A length is used as it is, and a number multiplies the border width on that side. The image draws over the outset area, outside the box, without moving anything in the layout, as in Chrome.
border-image-repeatHow the edge and middle slices fill their lengths:
stretch,repeat,roundorspace.The first value is for the top and bottom edges and the second for the sides.
stretchscales a slice to the length.repeattiles it from the middle of the edge, cutting tiles at both ends.roundscales it so a whole number fit.spacespreads whole tiles with even gaps, ends included, and draws none where none fit. An edge slice keeps its aspect, its cross size being the border image width.box-shadowDraws outer and inset shadows as vector paths, blurred as Chrome blurs them.
Offsets, blur and spread are drawn as vector paths following the box's
border-radius. A blur is a stack of layers, one per 2pt of blur up to 60, each ending where Chrome's Gaussian falls to its share, so the edge fades as Chrome's does, in fine steps a close zoom can show. An outer shadow is never drawn under its own box, so a translucent background doesn't show it. An inset shadow draws over the background and its layers, under the border.A transparent shadow draws nothing. An element draws its first 32 shadows, and a document draws 50,000 blur layers in all, after which each blurred shadow draws in one step, with a hard edge.
The first of several shadows is on top, as CSS puts it and Chrome's print draws it. An inline box broken over lines casts the shadow of the whole box laid end to end, each piece showing its part and the cut sides none, as Chrome's print slices it; with
box-decoration-break: cloneeach piece casts its own.box-decoration-breakslicecuts a broken box's border and corners at each break;clonedraws each piece as a whole box.An inline box broken over lines: with
slice, the default, its border and rounded corners draw only at the box's start and end, and its background layers run on as one strip across the pieces. Withclone, every piece has its own border and corners, and its background is laid out on it.A block over pages: with
slice, each page shows its part of one shape, the page's edge cutting the border and the background. Withclone, each page's part is a whole box of that part's height, with its border and rounded corners all around, as Chrome prints it, and its background layers are sized to the whole box and start again at each part's top, so a gradient shows its first stretch on every page.The outline is drawn whole around every piece either way. Under
slicethe pieces share onebox-shadow, cut where the box is; undercloneeach casts its own.outline-widthHow wide the outline is, drawn outward from
outline-offsetpast the border box.Chrome computes it to 0 when
outline-styleisnone. The outline is a ring around the border box, whole around every piece of the box: each line of an inline box and each page's part of a block. It takes no room in the layout. Adoubleoutline narrower than 3px draws solid, as Chrome draws it.Outlines paint last in the flow, as CSS orders them: over the box's own content and over a later box's background, still cut by the overflow clips around the box, as in Chrome's print.
outline-styleThe outline's style, drawn as the same style of border is.
solid,dashed,dotted,double,groove,ridge,insetandoutsetdraw asborder-top-styledescribes, a square dashed outline dashing side by side.autodraws Chrome's print's focus ring, whatever the width: 2px ofoutline-colorcentered on the outline's edge, inside 1px of white, its corners at least 2px round.outline-colorThe outline's color, its alpha kept as the PDF's opacity.
It arrives as Chrome computes it and is converted to sRGB, as
border-top-coloris. A transparent outline draws nothing.outline-offsetHow far outside the border box the outline starts; a negative offset draws it inside.
A positive offset leaves a gap between the border and the outline. A rounded box's outline has corners grown by the offset and the outline's width, as Chrome draws them, and square corners stay square.
daeepdf draws the outline with its box, under the box's content, where Chrome draws outlines over everything else in their stacking context. An outline moved inside by a negative offset can hide under a child's background in daeepdf and shows over it in Chrome.
Text
How a run of text looks once Chrome has laid it out: its color, spacing, case, wrapping and paint. daeepdf reads where Chrome put each line and word and draws the glyphs itself, so what a property changes in the layout, line breaks, alignment and spacing, prints where Chrome's print puts it, and what it changes in the painting is drawn as each entry says. Text prints only in a font the template declares with @font-face, or in fallbackFont.
colorThe text's color, which daeepdf fills the glyphs with.
Any color Chrome computes works: names, hex,
rgb(),hsl(),hwb(),lab(),oklch()andcolor()in every predefined space. daeepdf converts it to sRGB, each channel clipped to its range, and writes its alpha as the run's opacity, sorgb(0 0 0 / 0.5)prints half transparent. A decoration, a list marker and an SVG'scurrentColortake this color unless they set their own, and-webkit-text-fill-coloroverrides it for the fill alone.Text in a fully transparent color is invisible but stays in the PDF's text, so it can be found and copied, as in Chrome's print, and its
text-shadowprints. Its decorations still print. Two cases paint anyway:-webkit-text-strokeoutlines the glyphs, and text underbackground-clip: texttakes a stand-in color, as the-webkit-text-fill-colorentry says.import pdf from 'daeepdf' const file = await pdf.render(`<style> @font-face { font-family: Inter; src: url('/fonts/inter-var.ttf'); } p { font: 12pt Inter; } .note { color: transparent; } </style> <p>Total: 42</p> <p class="note">Hidden note</p>`) // 'Hidden note' doesn't show, but the PDF's text holds it beside 'Total: 42'line-heightThe height of each line, which Chrome lays out and daeepdf reads, deciding where lines sit and where a page breaks between them.
daeepdf takes each line's position from Chrome's layout and its baseline from the font, so any value,
normal, a number, a length or a percentage, prints with the spacing Chrome's print gives it.It also decides where a page breaks inside a paragraph. A line's box is its glyphs grown by the leading
line-heightadds, the whole px of the half-leading above and the rest below, as Chrome splits it, and a line whose box would cross the page's end moves to the next page,orphansandwidowskept.normalis measured from the line's first font: its ascent, descent and line gap.text-alignHow lines align in their box, which Chrome lays out and daeepdf prints where Chrome put each line.
left,right,center,startandendneed nothing of daeepdf: each line is drawn from where Chrome's layout starts it.justifywidens the spaces between words. daeepdf doesn't widen spaces inside a run of text, so a justified paragraph goes word by word, each word set where Chrome put it. It prints as Chrome's print does, word for word, the last line left as Chrome leaves it.text-align-lastsets the last line, and a line before a forced break, apart, as its own entry says.text-align-lastHow the last line of a block, and a line before a forced break, align.
justifyspreads that line across the box. daeepdf draws it word by word, as it draws justified lines, each word where Chrome's print sets it. Its other values only move where Chrome starts each line, which daeepdf reads, so they need nothing of it.text-transformChanges the text's case; daeepdf draws the changed text and puts it in the PDF's text, as Chrome's print does.
uppercase,lowercaseandcapitalizechange the characters daeepdf draws, so a searched or copied word reads as it prints. Letters of any script count, socapitalizemakesélanintoÉlan, and it sees a word across inline boxes as Blink does:wor<b>ld</b>becomesWorld, itslleft lowercase.uppercaseandlowercasemap case in the text's language, from the nearestlang, as Chrome's print does: underlang="tr",uppercaseturnsiinto the Turkishİ.capitalizemaps in no language, as Chrome's does, so thereizmirbecomesIzmir.import pdf from 'daeepdf' const file = await pdf.render(`<style> @font-face { font-family: Inter; src: url('/fonts/inter-var.ttf'); } h2 { font: 12pt Inter; text-transform: uppercase; } </style> <h2>Total due</h2>`) // The PDF's text is 'TOTAL DUE', so a search for it finds itletter-spacingSpace added after each character, which daeepdf sets as the PDF's character spacing.
Chrome lays out the spaced text and daeepdf gives the run the same spacing, so each glyph lands where Chrome's print puts it. Any length works, and a percentage of the font size.
As in Chrome, spacing other than 0 turns off the font's optional ligatures,
liga,clig,dlig,hligandcalt, whateverfont-variant-ligaturesasks for. In vertical text each character is placed where Chrome stepped it down the column, its spacing included.word-spacingSpace added at each space between words; daeepdf sets each word where Chrome put it.
daeepdf doesn't widen the spaces in a run of text, so a run with
word-spacinggoes word by word, each word at its place in Chrome's layout, as a justified line does. Word and letter spacing together print as Chrome's print has them. Any length works, and a percentage of the font size.white-spaceWhether the source's spaces and line breaks are kept or collapsed, which Chrome lays out and daeepdf follows.
Under
normal,nowrapandpre-line, spaces collapse and daeepdf draws a line's words as one run with single spaces. Underpre,pre-wrapandbreak-spacesthey are kept, and each word goes where Chrome put it, so a run of spaces or a tab prints as wide as Chrome laid it out.The spaces themselves are drawn, as Chrome draws them, so text taken from the PDF keeps its words apart; none is drawn where a line wraps.
text-overflowellipsiscuts a line too long for its box with…, which daeepdf draws as Chrome's print does.It applies on a block with an
overflowthat clips, to each line wider than the box, whatever itswhite-space: anowraporpreline, or a word too long to wrap. daeepdf measures the line in its fonts and keeps the longest part that fits with the…, a space before the cut included, drawn in the line's own font and color.clip, the default, leaves the line to the box's overflow clip.In right-to-left text the
…goes on the left, where the line overflows: a Hebrew line keeps its start, a line of Latin its end, as Chrome's bidi lays them out. Vertical text never gets one.import pdf from 'daeepdf' const file = await pdf.render(`<style> @font-face { font-family: Inter; src: url('/fonts/inter-var.ttf'); } p { font: 12pt Inter; width: 100px; white-space: nowrap; overflow: hidden; } p { text-overflow: ellipsis; } </style> <p>Abbreviation overflowing</p>`) // The PDF's text is 'Abbreviatio…', as Chrome's print cuts it-webkit-line-clampShows a box's first lines only, the last one shown ending in
…, as Chrome's print does.With
display: -webkit-box,-webkit-box-orient: verticalandoverflow: hidden, Chrome lays out every line and the box shows the first ones. daeepdf finds the last line the box shows, cuts it to fit with…astext-overflowdoes, and the box's overflow clip hides the rest. Lines in blocks inside the box count too.The lines past the clamp are clipped and left out of the PDF's text, as in Chrome's print. In right-to-left text the
…goes on the left.import pdf from 'daeepdf' const file = await pdf.render(`<style> @font-face { font-family: Inter; src: url('/fonts/inter-var.ttf'); } p { font: 12pt Inter; width: 120px; overflow: hidden; } p { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; } </style> <p>one two three four five six seven eight nine ten eleven twelve</p>`) // The second line ends 'four five six…'text-shadowShadows under the text, drawn from the glyphs' outlines and blurred as Chrome's print blurs them.
Each shadow is the run's glyph outlines filled in the shadow's color, at its offset and under the text, the last one listed lowest, as in Chrome. A sharp shadow is a vector shape; one with a blur radius is blurred by a Gaussian of half that radius, as Chrome draws it, on an image at 216 dpi. The color's alpha is the shadow's opacity. Shadows print on first letters and list markers too.
A shadow is a shape, not text, so the PDF's text holds each word once, as Chrome's print does.
One case stays as it was: in vertical text, or where a run's outlines can't be read, a shadow is a copy of the text, sharp at 55% of its alpha for a blur, which a text extraction reads again.
-webkit-text-fill-colorThe color the glyphs are filled with, overriding
colorfor the fill alone.daeepdf fills the glyphs in it, while
colorstill colors decorations and anything set tocurrentColor.transparentfills nothing. With-webkit-text-strokethat leaves the outline alone. Underbackground-clip: text, the gradient-text pattern, daeepdf doesn't clip the background to the glyphs: the text takes a stand-in color, the gradient's first stop or else the background color, and the box paints no background. Transparent text that is neither stroked nor clipped is invisible but stays in the PDF's text, as with a transparentcolor.-webkit-text-stroke-widthThe width of an outline along the glyphs' edges, which daeepdf draws with the PDF's own text stroke.
A width above 0, with
-webkit-text-stroke-color, outlines each glyph, the stroke centered on its edge, as Chrome's print strokes it. With-webkit-text-fill-color: transparentthe text is the outline alone; otherwise fill and outline print together. A synthesized bold widens the stroke by its own em/32.It applies wherever text prints: in lines, first letters, list markers and vertical text.
-webkit-text-stroke-colorThe color of the outline
-webkit-text-stroke-widthdraws.Nothing is stroked without a width above 0. Its alpha is the stroke's own, apart from the fill's, so a translucent outline around an opaque fill prints as Chrome's print has it. Left out, it is the text's
color.text-renderingA hint Chrome takes for shaping, which daeepdf follows where it changes the glyphs.
optimizeSpeedturns off the font'sliga,cligandcaltfeatures, as Chrome's print does, and keeps its kerning.auto,optimizeLegibilityandgeometricPrecisionchange nothing in the PDF.ruby-alignHow ruby text and its base spread across the width the wider one takes, which Chrome lays out and daeepdf prints.
Chrome spreads the narrower of a ruby's base and annotation by
ruby-align:space-around, the default,space-between,centerorstart. daeepdf reads the spread from where Chrome placed each character and draws the text in pieces at those places, so ruby prints as Chrome lays it out. The annotation prints in its own font and size, like any text.
Text decoration
Underlines, overlines and line-throughs, which daeepdf draws as lines of its own, placed and sized as Chrome's print places them. A decoration paints across the inline content of the box that sets it, its descendants' text included, up to a box out of flow, a float or an inline block, as in browsers. Underlines and overlines go under the glyphs and break where they cross them; a line-through goes over them.
text-decorationThe shorthand for a decoration's line, style, color and thickness; daeepdf reads the longhands it sets.
For HTML text daeepdf reads
text-decoration-line,text-decoration-style,text-decoration-colorandtext-decoration-thickness, sotext-decoration: underline wavy redprints as those say. The shorthand itself is read only for text in an inline SVG, carried onto the SVG daeepdf draws as an image.text-decoration-lineWhich lines decorate the text:
underline,overlineandline-through, alone or together.Each is a line daeepdf draws at the thickness and place Chrome's print gives it: an underline below the baseline by half its thickness, 1px at least, by
text-underline-offset, or wheretext-underline-positionputs it; an overline with its bottom at the font's ascent; a line-through a third of the ascent above the baseline.blinkdraws nothing, as in Chrome.A decoration isn't inherited, but it paints across the box's inline content, a
<span>inside an underlined link included, up to a box out of flow, a float or an inline block, as browsers paint it. A space between two decorated boxes is decorated too. Down a vertical column an underline runs on the left, unlesstext-underline-positionputs it on the right, and an overline on the right, as Chrome draws them.text-decoration-styleThe line's style:
solid,double,dotted,dashedorwavy.Each prints as Chrome's print draws it.
doubleis two lines of the thickness 1px apart, the second further from the text.dottedanddashedfollow Chrome's pattern, fitted so the line starts and ends on a dash.wavyis Chrome's wave, its wavelength, height and phase, and sits a thickness and 1px further from the text than a solid underline or overline.text-decoration-colorThe decoration's color, the text's
colorunless set.Its alpha is the line's opacity, and
transparentdraws no line. A decoration takes the color of the box that sets it, so a link's underline keeps the link's color under a differently colored<span>inside it, as in browsers.text-decoration-thicknessHow thick a decoration's line is.
auto, the default, is a tenth of the font size, floored to whole px and 1px at least, as Chrome paints it. A length, or a percentage of the font size, is rounded to whole px, 1px at least.from-fonttakes the font's own underline thickness, at the run's point in a variable font, floored to whole px; a font that states none takesauto's.text-decoration-skip-inkWhether underlines and overlines break where glyphs cross them.
auto, the default, breaks an underline or overline around each glyph that reaches into its band, the gap padded by the line's thickness up to 13px, and ignores ink reaching less than half a px in, as Chrome's print breaks it.nonedraws the lines whole. A line-through never breaks.It works down vertical columns too, and text that paints nothing, in a transparent color, still breaks its underline. A
text-combine-uprightcell's lines don't break.text-underline-offsetHow far below the baseline an underline's top edge sits, or how far past where
text-underline-positionputs it.auto, the default, is half the line's thickness, 1px at least. A length, or a percentage of the font size, is rounded to whole px and takes that gap's place. Undertext-underline-position: underorfrom-fontit moves the line on from where those put it, and down a vertical column it moves the line away from the text. It moves underlines only.text-underline-positionWhere an underline goes: near the baseline, clear of the descenders, where the font says, or which side of a vertical column.
auto, the default, puts it just below the baseline (seetext-underline-offset).underputs it a px below the em box, clear of descenders, andfrom-fontat the font's own underline position, read at the run's point in a variable font, each where Chrome's print places it. A font that states no position takesauto's.Down a vertical column the underline runs on the left, or on the right at
right. Text in Japanese or Korean, by itslang, takes the right unless it saysleft, as in Chrome. Text turned sideways takesunderandfrom-fontas horizontal text does.
Writing modes and direction
Right-to-left and bidirectional text, and text set in vertical columns. Chrome's own bidi and vertical layout place every character, and daeepdf reads those places and shapes each run in the direction it runs. Vertical text goes without a few things horizontal text has, an ellipsis, ::first-letter and ::first-line, and fallback to another font per character, and a column must fit on its page.
directionThe base direction of text,
ltrorrtl, which Chrome's bidi lays out and daeepdf follows.Chrome runs the Unicode bidi algorithm and places each word, and daeepdf reads those places. A line that mixes right-to-left letters with left-to-right ones, a brand name or a number in Hebrew or Arabic, goes word by word, each word where Chrome put it and each run in it shaped in its own direction, digits left to right.
A right-to-left line of left-to-right letters alone goes word by word too, so a neutral at its end lands where Chrome's bidi sets it:
Latin text!underdirection: rtlprints with the!on the left.It also places what daeepdf draws itself: a list marker goes right of its item, its brackets mirrored, and the
…oftext-overflow: ellipsisgoes on the left.unicode-bidiHow an element's text takes part in the bidi algorithm; daeepdf prints Chrome's result, overrides included.
normal,embed,isolateandplaintextchange only where Chrome's layout puts each word, which daeepdf reads.bidi-overrideandisolate-override, like U+202D and U+202E in the text, force the text's direction against its letters' own: daeepdf reads the pieces Chrome's bidi set the text in from each character's box and shapes each piece in its forced direction, in a line, down a column and under a filter.The PDF's text keeps the characters as written, so overridden text reads as it was written when copied or read aloud, where Chrome's print gives it reversed.
import pdf from 'daeepdf' const file = await pdf.render(`<style> @font-face { font-family: Inter; src: url('/fonts/inter-var.ttf'); } p { font: 12pt Inter; } .back { unicode-bidi: bidi-override; direction: rtl; } </style> <p><span class="back">override</span> plain</p>`) // The PDF's text reads 'override plain', as writtenwriting-modeSets text in vertical columns,
vertical-rl,vertical-lr,sideways-rlorsideways-lr, instead of horizontal lines.Chrome lays the columns out and daeepdf draws each character where Chrome placed it. Under
vertical-rlandvertical-lreach character stands upright or turns a quarter clockwise, astext-orientationsays. Undersideways-rlevery character turns a quarter clockwise, and undersideways-lra quarter counterclockwise, read bottom to top. The-rlmodes set their columns right to left and the-lrones left to right. Each glyph lands where Chrome stepped it down the column, an upright one centered across it.Vertical text keeps its color,
letter-spacing,text-shadow,-webkit-text-strokeand decorations. It goes without some of what horizontal text has: notext-overflowellipsis, no::first-letteror::first-line, and no fallback per character, so a column draws in its first declared family alone.A box whose writing mode differs from its parent's, such as a vertical box on a horizontal page, isn't broken inside, as Chrome's print doesn't break it: a page's end moves it whole to the next page, and one taller than a page starts a page and runs on across the ones after it, each column drawn on every page it reaches.
text-orientationHow characters stand in a vertical column:
mixed,uprightorsideways.Under
mixed, the default, CJK characters and most symbols stand upright while Latin and other horizontal scripts turn a quarter clockwise, cluster by cluster, by Unicode's vertical orientation data (UAX #50), as Chrome does.uprightstands every character upright, Latin included, andsidewaysturns them all. Right-to-left text in a turned run goes the other way along its line, in the order Chrome's bidi gives it.Under
sideways-rlandsideways-lrevery character turns whatever this says, and in horizontal text it changes nothing.text-combine-uprightallsets a short run, such as a date's two digits, upright and side by side in one character's cell of a vertical column.As in Chrome, the run takes the first of the font's half-, third- and quarter-width forms (
hwid,twid,qwid) that fits 1.1em, or 1em under an underline or overline, and is squeezed across to fit where none does. It has no letter spacing, and its decorations run down the cell without skip-ink.It applies under
vertical-rlandvertical-lr; in horizontal text and undersideways-rlandsideways-lrit changes nothing.
Fonts
Which font text prints in, and in which of its forms. A run prints only in a family the template declares with @font-face, or in fallbackFont, and daeepdf embeds a subset of that font, shaped by daegun, at the point in a variable font Chrome's print uses and with the OpenType features Chrome turns on. Where Chrome would make a bold, an oblique or small capitals the font doesn't have, daeepdf makes them the same way.
font-familyThe families text is set in; text prints only in one the template declares with
@font-face.daeepdf can't use the fonts installed on a machine. Each run takes the first family in its list that one of the template's own
@font-facerules declares, skipping generic names such assans-serifandserifand any family no rule declares. Text whose list names no declared family is left out, with a'font-not-declared'warning naming its first family, unlessfallbackFontgives it a font. Only rules in the template count: an@font-facein your app's stylesheets lays text out in the browser but can't print it. Headers and footers use the template's fonts.A character the chosen font lacks falls back on its own, to the next declared family in the list that has it, then to any other family the template declares. One that no declared font has prints as the font's placeholder glyph, or under
pdfAorpdfUAis left out, with a'glyph-missing'warning.Put a declared family first. A family before it that the machine has installed, as in
Arial, Inter, lays the text out in Arial in Chrome while daeepdf draws it in Inter, so lines break where Arial's narrower widths put them and print wider than Chrome laid them out. WithfallbackFontset, daeepdf takes the undeclared families out of the template'sfont-familylists before layout, so Chrome lays text out in the font that prints.import pdf from 'daeepdf' const file = await pdf.render(`<style> @font-face { font-family: Inter; src: url('/fonts/inter-var.ttf'); } p { font-size: 12pt; } </style> <p style="font-family: 'Brand Sans', Inter">Set in Inter</p> <p style="font-family: 'Brand Sans', serif">Left out</p>`) file.warnings.map((w) => w.code) // ['font-not-declared']font-sizeThe text's size, which daeepdf draws its glyphs at, scaled by its face's
size-adjust.Glyphs print at the computed size in pt, px × 0.75, times the
size-adjustof the@font-facerule the text's face comes from, as Chrome scales them. Sizes written inptcarry straight into the PDF:12pttext is 12pt type.In a variable font with an optical size axis, the glyph size in px also sets
opsz, unlessfont-optical-sizingisnone, and each optical size the document uses embeds an instance of its own.font-weightThe weight daeepdf draws in: a variable font's
wghtaxis, or a bold made from a lighter face, as Chrome's print does.In a variable font the weight sets
wght, clamped to the range the face's@font-facerule declares, as infont-weight: 100 900, or to the font's own axis where the rule declares none. Each weight the document uses embeds an instance of its own, so regular and bold text carry two subsets of one file.Where the face can't reach the weight, a static face or a rule whose range ends below 600, text at 600 or more gets a synthesized bold, as Chrome's print draws it: the glyphs stroked an em/32 wide in their own color.
font-synthesis-weight: noneturns that off.import pdf from 'daeepdf' const file = await pdf.render(`<style> @font-face { font-family: Inter; src: url('/fonts/inter-var.ttf'); font-weight: 100 900; } p { font: 12pt Inter; } </style> <p>Regular, <b>bold</b> and <span style="font-weight: 300">light</span></p>`) // Three subsets of Inter, at wght 400, 700 and 300font-styleItalic or oblique text, drawn from the font's own italic or slant, or slanted by daeepdf where it has neither, as Chrome's print does.
italictakes a variable font'sitalaxis, else itsslntaxis at 14°, clamped to thefont-stylerange of the face's@font-facerule;obliquewith an angle setsslntto that angle. A static italic face is taken foritalicand for anobliqueof 14° or more, which Chrome treats alike.A font that can't slant that far, Inter among them, gets a synthesized oblique, its glyphs sheared by 0.25, about 14°, as Chrome synthesizes it. An
obliqueunder 14° in such a font prints upright, as in Chrome, andfont-synthesis-style: nonekeeps every slant from being synthesized.font-stretchThe face's width, which a variable font's
wdthaxis draws.In a variable font with a
wdthaxis the stretch's percentage sets it, clamped to thefont-stretchrange of the face's@font-facerule;condensedand the other keywords are their percentages. A font without the axis, Inter among them, prints at its own width, as in Chrome: no width is synthesized.daeepdf doesn't choose between faces by it, so two
@font-facerules of one family that differ only infont-stretcharen't told apart. Give a condensed face a family of its own.font-size-adjustScales a font by its x-height, or the metric named, and daeepdf draws the glyphs at the size Chrome lays them out at.
Chrome scales the text so its x-height, or the metric named, is the given share of the font size, and lays the lines out at that size. daeepdf takes the size from Chrome's own layout of the font, with the optical size it sets, so "Hello wide world" at 12pt in Inter with
font-size-adjust: 0.3prints 52pt wide, as in Chrome's print.The
@font-facedescriptorsize-adjustis another thing, and prints as Chrome scales it (seefont-size).font-variantThe shorthand for the
font-variant-*properties; daeepdf reads the longhands it sets.For HTML text daeepdf reads
font-variant-caps,font-variant-numeric,font-variant-ligatures,font-variant-east-asian,font-variant-alternatesandfont-variant-position, which this sets. The shorthand itself is read only for text in an inline SVG, carried onto the SVG daeepdf draws as an image.font-variant-capsSmall capitals and their kin, from the font's own features where it has them and made from its capitals where it doesn't, as Chrome's print does.
daeepdf looks the features up for the script of the text's first cased letter:
small-capstakessmcp,all-small-capssmcpandc2sc,petite-capspcap,all-petite-capspcapandc2pc,unicaseunicandtitling-capstitl. Petite caps the font lacks become small caps.Small caps the font lacks, as in Inter, are synthesized: lowercase letters, or every letter under
all-small-caps, drawn as capitals at 70% of the size, rounded to whole pixels as Chrome rounds it.unicasewithoutunicshrinks the capitals instead, or lowercases them into the font'ssmcpwhere it has that. Titling caps are never synthesized, andfont-synthesis-small-caps: noneturns synthesis off.Synthesized capitals copy as the letters written, as in Chrome's print: "Small Caps" copies as "Small Caps", though it prints in capitals.
import pdf from 'daeepdf' const file = await pdf.render(`<style> @font-face { font-family: Inter; src: url('/fonts/inter-var.ttf'); } p { font: 12pt Inter; font-variant-caps: small-caps; } </style> <p>Small Caps</p>`) // Inter has no smcp, so the small capitals are made from capitals, and the PDF's text is still 'Small Caps'font-variant-numericFigure and fraction forms, each turning on the font's OpenType feature as Chrome does.
lining-numsturns onlnum,oldstyle-numsonum,proportional-numspnum,tabular-numstnum,diagonal-fractionsfrac,stacked-fractionsafrc,ordinalordnandslashed-zerozero. A font without the feature prints its default forms, as in Chrome: nothing is synthesized.List markers set their digits in tabular figures, as Chrome's
::markerstyle does.font-variant-ligaturesWhich ligatures the font may form, each value turning its OpenType features on or off as Chrome does.
common-ligaturesturns onligaandclig,discretionary-ligaturesdlig,historical-ligatureshligandcontextualcalt, and eachno-value turns the same ones off.noneturns all five off, andnormalleaves the font's own defaults. Letter spacing other than 0 turns all five off whatever this says, as in Chrome.font-variant-east-asianEast Asian glyph forms, each turning on the font's OpenType feature as Chrome does.
jis78,jis83,jis90andjis04turn onjp78,jp83,jp90andjp04;simplifiedsmpl,traditionaltrad,full-widthfwid,proportional-widthpwidandrubyruby. They change the glyphs only in a font with the features, a Japanese or Chinese one; in any other the text prints as it is.font-variant-alternatesAlternate glyphs, by keyword or by the names an
@font-feature-valuesrule gives them.historical-formsturns on the font'shistfeature, as in Chrome. The functions take names an@font-feature-valuesrule for the font's family sets:stylistic()turns onsalt,styleset()ss01toss20,character-variant()cv01tocv99with its value,swash()swshandcswh,ornaments()ornmandannotation()nalt, each at the number its name stands for. A name no rule sets turns nothing on, as in Chrome.import pdf from 'daeepdf' const html = `<style> @font-face { font-family: Inter; src: url('/fonts/inter-var.ttf'); } @font-feature-values Inter { @styleset { clear: 2; } } body { font: 12pt Inter; } .code { font-variant-alternates: styleset(clear); } </style> <p class="code">Il1 O0</p>` const file = await pdf.render(html) // The capital I, small l and 1 print in Inter's disambiguating forms (ss02).font-variant-positionSuperscript and subscript forms, from the font's
supsandsubsfeatures.superturns onsupsandsubturns onsubs, after every other feature. A character the font has no such form for prints at its normal size and place, as in Chrome's print: nothing is synthesized. For raised or lowered text in any font, usevertical-alignwith a smallerfont-size.font-feature-settingsOpenType features by tag, applied after those the other font properties turn on.
daeepdf hands the list to daegun's shaper as written, as in
"tnum","ss01" 1or"liga" 0, after kerning, ligatures, caps and thefont-variant-*forms, so it overrides them, and before letter spacing's ligatures-off andfont-variant-position, the order Chrome applies them in. A feature the font lacks does nothing. It applies in lines, first letters, list markers and vertical text, and under a filter or mask.font-variation-settingsSets a variable font's axes directly, after everything else that sets them.
daeepdf draws each run at the point in the font's design space Chrome's print uses: the weight, stretch, slant and optical size the other properties give, then the
@font-facerule's ownfont-variation-settings, then the element's, a later value for an axis winning. Values are clamped to the font's axes, and an axis it doesn't have is ignored. Each point the document uses embeds an instance of its own.import pdf from 'daeepdf' const file = await pdf.render(`<style> @font-face { font-family: Inter; src: url('/fonts/inter-var.ttf'); font-weight: 100 900; } p { font: 12pt Inter; font-variation-settings: 'wght' 250; } </style> <p>Thin text</p>`) // One subset of Inter, instanced at wght 250font-kerningWhether the font's kerning applies.
autoandnormalkeep the font'skernfeature on, as Chrome's print does, andnoneturns it off, so "AVATAR" sets wider. Glyphs land where Chrome's print puts them either way.font-optical-sizingWhether a variable font's optical size axis follows the text's size.
Under
auto, the default, daeepdf sets the font'sopszaxis to the glyph size in CSS px, as Chrome's print does: 12pt text is drawn atopsz16, clamped to the axis' range, 14 to 32 in Inter.noneleaves the axis at the font's default, andfont-variation-settingscan set it either way. Each optical size the document uses embeds an instance of its own.import pdf from 'daeepdf' const file = await pdf.render(`<style> @font-face { font-family: Inter; src: url('/fonts/inter-var.ttf'); } p { font: 24pt Inter; } </style> <p>Display</p> <p style="font-optical-sizing: none">Default</p>`) // Two subsets of Inter: one at opsz 32 for 24pt (32px) text, one at the font's defaultfont-synthesis-weightWhether daeepdf may make a bold from a face too light for the weight asked for.
Under
auto, the default, text at 600 or more in a face whose weight stops below 600 is drawn bold, its glyphs stroked an em/32 wide in their own color, as Chrome's print does.noneprints it at the face's own weight. A variable font that reaches the weight needs no synthesis.font-synthesis-styleWhether daeepdf may slant a face that has no italic of its own.
Under
auto, the default, text asking foritalic, or anobliqueof 14° or more, in a face that can't reach that slant is sheared by 0.25, as Chrome's print slants it.noneprints it upright, as in Chrome.font-synthesis-small-capsWhether daeepdf may make small capitals from a font's capitals.
Under
auto, the default,font-variant-capsin a font without the feature for it is drawn as capitals at 70% of the size, asfont-variant-capssays.noneprints the text as written, lowercase at full size, as in Chrome.srcThe
@font-facedescriptor naming a font's file, which daeepdf fetches and embeds.daeepdf reads the
srcof each@font-facerule in the template's own<style>blocks and takes oneurl()from it: the first whoseformat()saystruetype,opentypeorcollection, or whose path ends in.ttf,.otfor.ttc, else the firsturl()listed.local()entries are passed over. So one list can serve a WOFF2 to the browser and a TTF to daeepdf.The file is fetched in the browser, so it must be served over HTTP or HTTPS, and arrive within
loadTimeout. daeepdf tells the format from the file's own bytes: TTF, OTF and the first font of a TTC embed, CFF2 included. A file that fails to fetch or arrives too late, one over 64 MB (font-file), and a WOFF, a WOFF2 or any other format aren't embedded, each with a'font-not-loaded'warning saying why. Text in that family then takes the next declared family in its list, or is left out with'font-not-declared', or prints infallbackFont.import pdf from 'daeepdf' const file = await pdf.render(`<style> @font-face { font-family: Inter; src: url('/fonts/inter-var.woff2') format('woff2'), url('/fonts/inter-var.ttf') format('truetype'); } p { font: 12pt Inter; } </style> <p>From the TTF</p>`) file.warnings // []: daeepdf took the TTF and never asked for the WOFF2 const bad = await pdf.render(`<style> @font-face { font-family: Logo; src: url('/images/logo.png'); } </style> <p style="font-family: Logo">Left out</p>`) bad.warnings.map((w) => w.code) // ['font-not-loaded', 'font-not-declared']
Lists and generated content
List markers, the content of ::before, ::after and ::marker, and the counters and quotes they draw on. daeepdf counts and draws these itself, by CSS Lists 3 and CSS Counter Styles 3 as Chrome implements them, in the template's declared fonts. Their text goes into the PDF's text, so a copied list keeps its numbers.
list-style-typeThe marker before each list item, which daeepdf draws: a shape, the item's number in a counter style, or a string.
disc,circle,square,disclosure-openanddisclosure-closedare drawn as shapes, sized from the marker font's ascent as Chrome draws them, so a font without•doesn't matter. Every other predefined style of CSS Counter Styles 3 writes the number, fromdecimalandlower-romantoarmenian,hebrew,cjk-decimalandjapanese-formal, as does a style from the template's own@counter-stylerules, with its prefix and suffix. A quoted string is drawn as written, andnonedraws nothing.Numbers come from the
list-itemcounter in document order, sostart,reversed,valueand nested lists number as in Chrome. A value a style can't write, a Roman numeral past 3999, goes to its fallback, decimal in the end, and a name no style has,upper-greekamong them, is decimal, as in Chrome.The marker is text in the marker's font, falling back per character, its digits tabular. In tagged output a list states its numbering: Disc, Circle, Square, Decimal, the Roman and alphabetic styles, else Ordered or Unordered.
import pdf from 'daeepdf' const file = await pdf.render(`<style> @font-face { font-family: Inter; src: url('/fonts/inter-var.ttf'); } body { font: 12pt Inter; } </style> <ol start="3" style="list-style-type: lower-roman"><li>Scope</li><li>Terms</li></ol> <ul style="list-style-type: '– '"><li>Draft</li></ul>`) // The markers are text: 'iii.', 'iv.' and '–'list-style-positionWhether the marker hangs outside the item's box or starts its first line.
outside, the default, hangs the marker before the item's border box on its first line, after it in a right-to-left list, whatever the item's padding, indent or alignment, as Chrome draws it.insidesets it at the start of the first line's content, wherever that line is aligned. Either way it sits on the first line's baseline.list-style-imageAn image in place of the marker.
A
url()image,image-set()included, prints at its own size with its bottom on the first line's baseline, 7px before the item. A gradient, which has no size of its own, is a square half the marker font's ascent wide. An image that doesn't load leaves thelist-style-typemarker in its place, as in Chrome, and::markercontent other thannormalwins over it.contentWhat
::before,::afterand::markerhold, which daeepdf lays out and prints as real text and images.daeepdf stands a real box carrying the pseudo-element's computed style in its place, so its content lays out, wraps and prints like any other text: strings, their CSS escapes decoded,
counter()andcounters()in any counter style,attr(), the quote keywords thatquotesfills, and images,url()and gradients, sized as Chrome sizes them. On::markerit replaces the marker, andnoneremoves it.A list holding a term daeepdf can't resolve is dropped whole, rather than printing raw CSS. Alt text after a
/, as incontent: url(icon.svg) / "Warning", makes the content a taggedFigurewith that alt text; an empty one marks it decorative. Its text needs a declared font, like any text.import pdf from 'daeepdf' const file = await pdf.render(`<style> @font-face { font-family: Inter; src: url('/fonts/inter-var.ttf'); } body { font: 12pt Inter; } ol { list-style: none; counter-reset: item; } li { counter-increment: item; } li::before { content: counters(item, ".") ") "; } a::after { content: " (" attr(href) ")"; } </style> <ol><li>Terms<ol><li>Payment</li></ol></li></ol> <p><a href="https://example.com">Example</a></p>`) // The PDF's text reads '1) Terms', '1.1) Payment' and 'Example (https://example.com)'quotesThe marks
open-quoteandclose-quoteinsert, and those a<q>prints.A list of string pairs, the outer pair first, each level of quotes in the document taking the next pair.
auto, the default, takes Chrome's marks for the language of the nearestlang, a<q>'s parent's: “ ” and ‘ ’ for English and for any language Chrome doesn't name, „ “ for German, « » for French, 「 」 for Japanese and so on.noneprints no marks, andno-open-quoteandno-close-quotechange the level without one.import pdf from 'daeepdf' const file = await pdf.render(`<style> @font-face { font-family: Inter; src: url('/fonts/inter-var.ttf'); } p { font: 12pt Inter; quotes: auto; } </style> <p lang="de">Er <q>sagte</q> nichts.</p>`) // German marks: 'Er „sagte“ nichts.'counter-resetStarts a new instance of a counter, at 0 or the value given.
The instance is in scope for the element, its descendants and its following siblings, and one an earlier sibling made is replaced rather than nested, as CSS Lists 3 says. Counters hold 32-bit values, as in Chrome.
A list,
<ol>,<ul>or<menu>, resetslist-itemfor its items unless the author'scounter-resetnameslist-item.contain: stylescopes counters as Chrome does, and a table's repeated header and footer rows don't count.counter-incrementAdds 1, or the step given, to a counter's innermost instance.
It applies after
counter-resetand beforecounter-seton the same element or pseudo-element, and a pseudo-element's increment counts for content after it. With no instance in scope it makes one, as if reset to 0 first. A list item stepslist-itemby 1, or by −1 in a reversed list, unless the author'scounter-incrementnameslist-item.counter-setSets a counter's innermost instance to a value.
It applies after
counter-resetandcounter-incrementon the same element, socounter-increment: secwithcounter-set: sec 9leaves 9, as in Chrome. With no instance in scope it makes one. On a list item,counter-set: list-itemsets the item's number, as itsvalueattribute does.import pdf from 'daeepdf' const file = await pdf.render(`<style> @font-face { font-family: Inter; src: url('/fonts/inter-var.ttf'); } body { font: 12pt Inter; counter-reset: sec; } h2 { font-size: 12pt; counter-increment: sec; } h2::before { content: "§" counter(sec, upper-roman) " "; } .annex { counter-set: sec 9; } </style> <h2>Scope</h2> <h2 class="annex">Annex</h2>`) // The headings print '§I Scope' and '§IX Annex'
Pages, columns and tables
Chrome lays the template out on one long sheet, and daeepdf's own pagination then moves what each page's end would cut, as Chrome's print moves it: a line whose line box crosses the end, an image, a box that avoids breaks, a table row that can't split there. Forced breaks, avoid before, after or inside a box, orphans and widows steer it. Columns and tables are laid out by Chrome; daeepdf draws column rules itself, resolves a collapsed table's borders, and repeats a table's header and footer rows on each page it reaches.
break-beforeStarts a new page before the box with
page,left,right,rectoorverso;avoidkeeps it with the box before.daeepdf's pagination puts a forced break where Chrome's print puts it: the box starts the next page, its top margin kept. All five values break once. Neither daeepdf nor Chrome's print adds a blank page to land a box on a left or right page, and a break before the document's first box adds no blank page either. The legacy
page-break-before: alwayscomputes topageand works the same.It takes effect only between block-level boxes in flow, as in Chrome: not on an inline or inline-block box, a float, an absolutely positioned box or
display: contents. A break on a table cell falls at its row, and one on any item of a row flex container, a line of a wrapping one or a grid row falls before that whole row, the first row's before the container, as Chrome's print breaks it. A column flex container's items break one by one.columnbreaks a column of a multi-column box, which Chrome's layout does itself, and doesn't start a page.avoidandavoid-pagekeep the box on the page of the box before it. When a page's end falls between them, the break moves back to the latest place on that page that avoids none, as in Chrome's print: between the last lines of the box before, whenorphansandwidowsboth hold there, else before that box, which goes on with this one. A first child's value counts for its parent, and a table row takes it too. The legacypage-break-before: avoidis the same.import pdf from 'daeepdf' const html = `<style> @font-face { font-family: Inter; src: url('/fonts/inter-var.ttf'); } body { font: 12pt Inter; } h1 { break-before: page; } </style> <h1>Chapter 1</h1><p>It begins.</p> <h1>Chapter 2</h1><p>It goes on.</p>` const file = await pdf.render(html) file.pages // 2: the first chapter opens page 1, with no blank page before itbreak-afterStarts a new page after the box with
page,left,right,rectoorverso;avoidkeeps it with the box after.The next box starts a new page, as with
break-beforeon it, and the same rules apply: block-level boxes in flow only, and one page for all five values. A break after the document's last box adds no blank page, and an empty element, an<hr>say, still breaks. A break after a box's last child reaches the box after its parent, throughdisplay: contentstoo. On a row flex container's or a grid's item it falls after the item's whole row, the last row's after the container.avoidandavoid-pagekeep the box on the page of the box after it, asbreak-before: avoiddescribes: a heading that a page's end would leave at the foot of a page goes on to the next with its paragraph, as the example shows, and a run of headings goes together. A last child's value counts for its parent.import pdf from 'daeepdf' const html = `<style> @font-face { font-family: Inter; src: url('/fonts/inter-var.ttf'); } body { font: 12pt/1.5 Inter; } .spacer { height: 800pt; } h2 { font: bold 12pt/1.5 Inter; margin: 0; break-after: avoid; } </style> <div class="spacer"></div> <h2>Delivery terms</h2> <p>Goods ship within 5 working days of payment, by tracked post, to the address on the order.</p>` const file = await pdf.render(html) // The paragraph doesn't fit below the heading, so the heading starts page 2 with it.break-insideavoidandavoid-pagemove a box that a page's end would cut to the next page, whole.A box that avoids breaks inside and crosses a page's end starts the next page instead, as in Chrome's print. It works on any block-level box, and on a table row, which otherwise splits at the page's end as Chrome splits it.
avoid-columnandavoid-regiondon't keep a box off a page's end. A forced break inside such a box still splits it there.A box too tall for a page still has to split. As in Chrome's print, it first moves to the top of the next page, unless it starts its page already, and splits from there.
import pdf from 'daeepdf' const html = `<style> @font-face { font-family: Inter; src: url('/fonts/inter-var.ttf'); } body { font: 12pt/1.5 Inter; } .spacer { height: 760pt; } .card { break-inside: avoid; border: 1pt solid #999; padding: 8pt; } </style> <div class="spacer"></div> <div class="card"><b>Order 1042</b><br>2 x Notebook, A5<br>1 x Fountain pen<br>Total: 34.00 EUR</div>` const file = await pdf.render(html) // The card would straddle the page's end, so it starts page 2, whole.orphansThe fewest lines of a block's text that stay at the foot of a page before a break, 2 by default.
When a page's end would leave fewer lines above it, the whole run of text moves to the next page, with its block when the run starts the block, as Chrome's print moves it. With a page's end two lines into an 80-word paragraph,
orphans: 3moved the paragraph whole and the default split it after 27 words, on the same pages as Chrome's print.Lines are counted per run of a block's own text: a nested block starts a new run, and an inline image or inline-block is one line. It applies in table cells and list items as in any block, and a row whose cell can't keep its first lines above a page's end moves whole.
orphans: 1lets a single line stay.widowsThe fewest lines of a block's text that carry over to the top of the next page, 2 by default.
When a page's end would leave fewer lines below it, the break moves up so that many go over together, as long as
orphanslines still stay behind, as in Chrome's print. With a page's end five lines into a seven-line paragraph,widows: 3moved the break up a line, so four lines stayed and three went over, on the same pages as Chrome's print.It counts lines as
orphansdoes, per run of a block's own text.column-countRead for the column rules and the page breaks: a box fills its columns to a page's end and goes on below.
Chrome lays the columns out and daeepdf prints each line where it landed. daeepdf reads
column-countandcolumn-widthitself to find the used number of columns, which places the column rules (seecolumn-rule-style).A multi-column box crossing a page's end fills its columns one after another up to the end, and the rest goes on at the top of the next page, balanced there if the box ends there, as Chrome's print fragments it. A numbered list in columns counts on across the break, and the box's border, padding and margin are cut at it, as
box-decoration-break: slicecuts them. Acolumn-span: allelement breaks the box into column sets as Chrome's do. A vertical box on a horizontal page isn't split into its columns: it goes whole, as any box whose writing mode differs from its parent's does (seewriting-mode).column-widthRead with
column-countfor the used number of columns, which places the column rules.Chrome fits as many columns at least this wide as the box holds, and daeepdf works the count out the same way, as CSS Multi-column defines it, to place a rule in each gap. A box with
column-widthbreaks across pages as one withcolumn-countdoes (seecolumn-count).column-gapRead to center each column rule in its gap; the layout itself is Chrome's.
normalis 1em, as in Chrome, and a percentage is of the box's content width. daeepdf reads the gap only for a multi-column box's rules; a flex or grid gap reaches the PDF through the layout.column-rule-widthDraws column rules this wide, as vectors; 0 draws none.
A rule is drawn in each gap between two columns that hold content, centered in the gap and as tall as the box's content box, as Chrome draws it, and a box asking for more columns than its content fills draws none past the last. A
doublerule under 3px draws solid, as in Chrome.In a vertical writing mode the columns stack down the page, and each rule runs across it between two of them, as in Chrome's print.
column-rule-styleDraws column rules in any border style: solid, dashed, dotted, double, groove, ridge, inset or outset.
Dashes and dots follow Chrome's pattern, fitted so a rule starts and ends on a dash. A rule draws its 3D styles as a collapsed table's border does, as CSS says:
insetasridgeandoutsetasgroove, in Chrome's shades.noneandhiddendraw no rule.column-rule-colorThe rules' color, translucent ones included.
Its alpha is kept as the rule's opacity in the PDF, and the 3D styles take their light and dark shades from it as Chrome computes them. A transparent color draws nothing.
border-collapsecollapsemakes daeepdf resolve the table's borders itself and draw one per edge of its grid.In a collapsed table, the table, its rows, row groups, columns and cells draw none of their own borders. Each edge of the grid draws one, the winner among the parts meeting there as CSS 2.1 resolves it:
hiddenwins, then the widest, then the style ranked higher (double,solid,dashed,dotted,ridge,outset,groove,inset), then the cell before its row, row group, column, column group and table. Each is centered on its grid line and painted above the parts' backgrounds, as Chrome paints it, right-to-left tables and 3D styles included.On the pages a table continues onto, the borders stay those resolved on page 1, a border the break cuts split in Chrome's halves, and a repeated header or footer row draws its borders again. A collapsed table and its cells take no
border-image. In the defaultseparatemode, each cell draws its own border box,border-spacingapart.With a caption, the table's background and border cover its grid only, the caption outside them, as Chrome's print paints them (see
caption-side).border-spacingRead by the layout, and by daeepdf's pagination for the space a break leaves between rows.
Chrome spaces the cells and daeepdf draws them where they land. Its pagination reads the vertical spacing for the rows it moves at a page's end, the room a repeated footer takes, and a hidden row's space. In a collapsed table it is 0.
A
<thead>repeated on a later page starts at the page's top, as in Chrome's print, the spacing a page's end falls in dropped, whatever the spacing. To get there daeepdf splits the row group at the break, as an empty group adds no spacing, so a selector such astbody + tbodycan match the rows after a break.caption-sideRead by the layout, and by daeepdf's pagination to know whether a caption sits above the table's rows.
Chrome places the caption above or below the table, and daeepdf prints it there. A
bottomcaption follows the last row, on the table's last page. The pagination reads the side for where the table starts: a forced break before a table's first row moves the whole table unless a caption sits above the row, and a collapsed table's repeated header leaves room for the table's top border from below a top caption.The table's border and background go around its rows alone, the caption outside them at either side, as Chrome's print paints them, separated or collapsed.
Transforms and effects
A 2D transform, opacity, a blend mode and a clip-path shape are vector operations in the PDF, so what they apply to stays text, paths and sharp images. A filter or a mask has no PDF operator: the element is drawn as one image at 216 dpi, as Chrome draws it, with its text written invisibly over the image so it can still be selected and searched, and its links and form fields live above it. A 3D transform has no flat form, so the element prints where it would untransformed, with an 'unsupported-css' warning.
transformDraws a 2D transform as a matrix in the PDF, about
transform-origin; a 3D one prints untransformed.A 2D transform,
rotate(),scale(),skew(),translate()ormatrix(), prints as Chrome draws it, and so does a 3D function whose result is flat, such astranslate3d(30px, 0, 0)ortranslateZ(0). The element and all it holds are drawn untransformed and placed by one matrix, so text stays text, vectors stay vectors and images stay sharp. A link's or form field's area becomes the box around its transformed area, as a PDF annotation can't turn.A transform whose matrix isn't flat, from
rotateX(),rotateY(),perspective()or amatrix3d()with depth, has no 2D form. daeepdf prints the element where it would be untransformed, its own 2D part left out too, and warns with'unsupported-css'once per export, where Chrome's print draws the projection.It applies to block-level and atomic inline boxes, not to an inline box, as in Chrome. A transformed box starts a stacking context and holds its
position: fixeddescendants, which print once inside it instead of on every page. The pivot andtranslate()percentages use the boxtransform-boxnames, the border box by default.Under a rotation the text is still text in the file, in its order. Some extractors, poppler's among them, break a line that isn't level into pieces, as the example shows.
import pdf from 'daeepdf' const html = `<style> @font-face { font-family: Inter; src: url('/fonts/inter-var.ttf'); } body { font: 12pt Inter; } .stamp { display: inline-block; margin: 40pt; transform: rotate(-12deg); border: 2pt solid #c00; } </style> <p class="stamp">Paid in full</p>` const file = await pdf.render(html) // The words are still text, turned and in order; poppler's text breaks the turned line apart.translateMoves the element, before
rotate,scaleandtransformapply, as CSS orders them.One or two lengths or percentages, of the border box's width and height, print as Chrome draws them. A third, z value other than 0 makes it 3D: the element prints untransformed, its x and y moves left out too, with an
'unsupported-css'warning (seetransform). It applies wheretransformdoes.rotateTurns the element about
transform-origin, aftertranslateand beforescaleandtransform.An angle, or a turn about the z axis written as
z 30degor0 0 1 30deg, which Chrome computes to the same angle, prints as Chrome draws it. A turn about the x or y axis, or another axis, is 3D: the element prints untransformed with an'unsupported-css'warning (seetransform).scaleScales the element about
transform-origin, aftertranslateandrotateand beforetransform.One number or percentage scales both axes, two scale each, and both print as Chrome draws them; text scales as glyphs, not as an image. A third value other than 1 is 3D, so the element prints untransformed with an
'unsupported-css'warning (seetransform).transform-originThe pivot of
transform,rotateandscale, placed from the reference box's top left corner.daeepdf reads the origin Chrome computes, in px, and places it from the reference box's top left corner, so keywords, lengths and percentages print as Chrome draws them,
0 0andright bottomincluded. A z value is left out, as no depth is drawn.On an HTML box under
transform-box: content-boxorfill-boxthe origin is placed from the content box instead, as in Chrome (seetransform-box). In an inline<svg>, a shape's origin is folded into its matrix as itstransform-boxplaces it.transform-boxThe box a transform's origin and percentages resolve against, on HTML boxes and SVG shapes alike.
In an inline
<svg>, a CSStransformon a shape is written into the shape's own matrix with itstransform-origin, measured from the user space's origin forview-box, the default, or from the shape's fill bounding box for the other values. The shape stays a vector path, as Chrome draws it.On an HTML box,
content-boxandfill-boxresolve the pivot andtranslatepercentages against the content box, andborder-box, the default,stroke-boxandview-boxagainst the border box, as Chrome's print turns it.transform-styleRead only for which box holds
position: fixeddescendants: one withpreserve-3dholds them.daeepdf draws no depth, so
preserve-3dchanges nothing in how the box or its children print, and a child's 3D transform prints untransformed with an'unsupported-css'warning (seetransform). As in Chrome's print,preserve-3dmakes the box hold its fixed descendants, which then print once, inside it, instead of on every page.perspectiveRead only for stacking and fixed descendants; the 3D transforms it gives depth to print untransformed.
perspectivesets how a child's 3D transform is projected, and daeepdf draws no 3D transforms: the child prints where it would untransformed, with an'unsupported-css'warning, where Chrome's print draws it in perspective.perspective-originisn't read.On its own the property starts a stacking context and holds
position: fixeddescendants, as in Chrome's print, and daeepdf reads it for those.import pdf from 'daeepdf' const html = `<style> @font-face { font-family: Inter; src: url('/fonts/inter-var.ttf'); } body { font: 12pt Inter; } .stage { perspective: 600px; } .card { transform: rotateY(25deg); border: 1pt solid; padding: 12pt; } </style> <div class="stage"><div class="card">Front of the card</div></div>` const file = await pdf.render(html) file.warnings.map((w) => w.code) // ['unsupported-css']: the card prints flat, untransformedopacityFades the element and all it holds as one layer, a transparency group in the PDF, as Chrome's print does.
An element with
opacitybelow 1 is drawn as an isolated transparency group, faded as a whole, as Chrome composites it: where its contents overlap, only the top one shows, and its text keeps its own color over its background before the fade. Nested opacities each fade their own group. The text inside stays text, tagged in the group, and its links and fields stay live above it.Under a
filteror a mask the element is drawn as one image, which takes the opacity whole, as in Chrome. In an SVG drawn as vectors, a group's opacity is multiplied into its shapes.opacity: 0leaves the element out of the PDF, its text, links and form fields with it, as Chrome's print does; its counters still count and its ids are still link targets.color: transparentis another thing: the text is invisible but stays in the PDF's text (seecolor).import pdf from 'daeepdf' const html = `<style> @font-face { font-family: Inter; src: url('/fonts/inter-var.ttf'); } body { font: 12pt Inter; } .faded { opacity: 0; } .hidden { visibility: hidden; } </style> <p class="faded">Draft: price to be agreed</p> <p class="hidden">Internal: cost 12.40</p>` const file = await pdf.render(html) // Neither line shows, and neither one's text is in the PDFmix-blend-modeBlends the element with what lies under it in its stacking context, in all 15 of the PDF's modes.
multiply,screen,overlay,darken,lighten,color-dodge,color-burn,hard-light,soft-light,difference,exclusion,hue,saturation,colorandluminosityare blend modes in the PDF too, so the element stays vectors and text.plus-lighterprints asnormal, as Chrome's print draws it.A stacking context with a blending element inside is drawn as an isolated transparency group, so the blend mixes only with what that context draws, as CSS defines. The blending element is a group of its own, blended as one finished layer, as in Chrome's print: children that overlap inside it don't blend with each other.
Under a
filteror a mask, the canvas draws the same blends. In an SVG drawn as vectors, a shape's blend works the same way, and an SVG element that isolates it, byisolation,opacityor a blend of its own, is drawn as one group.filterDraws the element as one image through the filter, at 216 dpi, its text written invisibly over it.
A PDF has no filters, so daeepdf draws the element on a canvas as it would without one, then runs the filter over it, as Chrome draws it:
blur(),brightness(),contrast(),drop-shadow(),grayscale(),hue-rotate(),invert(),opacity(),saturate()andsepia(), chained in order. The image covers the element and all it paints past its box, grown by a blur's or shadow's reach or a<filter>'s region, at 3 pixels per point (216 dpi), scaled down past 16 megapixels.The text is in the image as pixels, and also written invisibly over it, so it can be selected, searched and read aloud, and a
blur()hides nothing from anyone reading the file, as the example shows; withaccessible: falseit is pixels only. Links and form fields stay live above the image.filter: url(#id)naming an SVG<filter>in the page runs the image through it, by Chrome's own SVG filters, its region and lengths laid on the element's border box in CSS px, as Chrome lays them, and the list can mixurl()with the functions. Aurl()naming no<filter>is passed over and the rest of the list applies, as in Chrome's print. A primitive inobjectBoundingBoxunits measures the image's box rather than the element's.With a mask too, the element is filtered first and then masked, and a
clip-pathcuts the result. A filter holds the element'sposition: fixeddescendants, as in Chrome. On an element inside an<svg>, afiltersends the whole SVG to the image path (see the SVG area).import pdf from 'daeepdf' const html = `<style> @font-face { font-family: Inter; src: url('/fonts/inter-var.ttf'); } body { font: 12pt Inter; } .blurred { filter: blur(4px); } </style> <p class="blurred">Card number 4111 1111 1111 1111</p>` const file = await pdf.render(html) // The number prints blurred, as an image, and is still in the PDF's text.clip-pathClips the element to a shape, a box, an SVG
<clipPath>or ashape()path, as a vector clip.inset(),circle(),ellipse(),polygon(), withevenoddtoo, andpath()print as Chrome clips them, and so dorect()andxywh(), which Chrome computes toinset(). The shape is laid out on the border box, or on the box written beside it:margin-box,padding-box,content-box, and on an HTML boxfill-box,stroke-boxandview-box, which mean the border box. It cuts the element's own box, shadow and all it holds, and what it hides wholly is left out of the PDF, links and form fields included.url(#id)naming an SVG<clipPath>in the page clips to its shapes, laid out in CSS px from the border box's corner, or on the border box itself withclipPathUnits="objectBoundingBox"; their transforms,<use>and a lone shape'sclip-ruleare read, and text in it leaves the element unclipped. A box on its own, such aspadding-box, clips to that box, its corners curved as the border radius makes them.shape()is read command by command,arc,curveandsmoothincluded. Any value makes a stacking context. On an<svg>or an element inside one, a value daeepdf doesn't draw itself is left in the SVG, which then goes to the image path, where Chrome draws it.Over several pages, each page's piece of the element is clipped on its own, as Chrome's print clips it. A shape repeated on the pages it spans copies at most 1,000,000 path segments per export, and later copies clip to their bounding box, with a
'limit-reached'warning.maskThe shorthand: daeepdf reads the mask longhands it sets, and
url()naming an SVG<mask>masks by it.On an HTML box,
masksetsmask-image,mask-position,mask-size,mask-repeat,mask-compositeand the rest, and daeepdf reads those, so a mask of gradients and image files prints as they say.mask: url(#id)naming an SVG<mask>element masks the element by it, as Chrome's print does: the<mask>is drawn over the border box, its content in user space orobjectBoundingBoxunits, its styles and what it references with it. An id that names no<mask>masks nothing. Its text is written invisibly where it stood, as for any masked element.On an element inside an
<svg>, amasksends the whole SVG to the image path, where Chrome draws it.import pdf from 'daeepdf' const html = `<style> @font-face { font-family: Inter; src: url('/fonts/inter-var.ttf'); } body { font: 12pt Inter; } .soft { mask: url(#fade); } </style> <svg width="0" height="0"> <mask id="fade" maskContentUnits="objectBoundingBox"><rect width="1" height="1" fill="white"/></mask> </svg> <p class="soft">Masked by an SVG mask</p> <p>Plain text</p>` const file = await pdf.render(html) file.warnings // []: the paragraph prints through the <mask>, which shows all of it // Its text is in the PDF, written over the masked image.mask-imageMasks the element by its layers' alpha, drawing it as one image at 216 dpi, its text written invisibly over it.
Each layer is a gradient, linear, radial or conic, repeating or not, a
url()image, an SVG one included, or animage-set(), of which daeepdf takes the option of highest resolution. Layers are laid out over the border box as backgrounds are, bymask-size,mask-positionandmask-repeat, and combined bymask-composite; the first 32 are drawn. The element is drawn as it would be without a mask on a canvas at 3 pixels per point, kept where the mask is opaque, and cut to the border box, as Chrome draws it.As under a
filter, the text is also written invisibly over the image, and links and form fields stay live above it. A filter and a mask together are filtered first, then masked.A layer masks by its alpha, or by its luminance under
mask-mode: luminance(seemask-mode).mask-originandmask-cliparen't read: layers are placed and cut at the border box, their default.A layer that doesn't load, a missing file or a cross-origin image served without CORS headers, adds nothing, with an
'image-skipped'warning. A mask none of whose layers paints leaves the element unmasked, as Chrome's print shows it.mask-sizeSizes each mask layer's tile, as
background-sizesizes a background's.auto,contain,cover, lengths and percentages of the border box, one per layer, are read as Chrome computes them. An SVG image with only aviewBoxtakes its ratio, and a tile of no size adds nothing.mask-positionPlaces each mask layer's first tile in the border box, as
background-positionplaces a background's.Keywords, lengths, percentages and the four-value form resolve against the border box less the tile, so
centercenters it, as in Chrome. Layers are placed in the border box whatevermask-originsays.mask-repeatTiles each mask layer:
repeat,repeat-x,repeat-y,no-repeat,spaceorround, as Chrome tiles it.Tiles are laid out as a background's are (see
background-repeat), and any number of them is drawn as one pattern fill per layer. Withno-repeat, the box outside the one tile is masked out.mask-compositeCombines each mask layer with the layers below it, as Chrome's print does:
add,subtract,intersectorexclude.Layers combine from the bottom up, each with the result of those below it, inside its own tiles only, as Chrome's print composites them:
addlays the layer over them,subtractkeeps it where they're clear andintersectwhere they're opaque. Outside the layer's tiles the layers below are left as they are, so a small circle subtracted from a layer covering the box prints the box with a hole.excludeprints asadd, as Chrome's print draws it (its PDF backend has no exclusive or); on screen Chrome shows only where exactly one of the two is opaque.-webkit-mask-imageThe prefixed
mask-image, one property with it in Chrome, which daeepdf reads the same way.Chrome keeps
-webkit-mask-imageandmask-imageas one property, so either name sets what daeepdf reads, and the two print alike.-webkit-mask-sizeThe prefixed
mask-size, one property with it in Chrome, which daeepdf reads the same way.Chrome keeps
-webkit-mask-sizeandmask-sizeas one property, so either name sets what daeepdf reads, and the two print alike.-webkit-mask-positionThe prefixed
mask-position, one property with it in Chrome, which daeepdf reads the same way.Chrome keeps
-webkit-mask-positionandmask-positionas one property, so either name sets what daeepdf reads, and the two print alike.-webkit-mask-repeatThe prefixed
mask-repeat, one property with it in Chrome, which daeepdf reads the same way.Chrome keeps
-webkit-mask-repeatandmask-repeatas one property, so either name sets what daeepdf reads, and the two print alike.-webkit-mask-compositeThe prefixed
mask-composite, its old WebKit keywords included, which print as Chrome's print draws them.Chrome keeps
-webkit-mask-compositeandmask-compositeas one property, so either name sets what daeepdf reads, and the two print alike foradd,subtract,intersectandexclude.Chrome also takes the old WebKit keywords here, and
mask-compositecomputes to them. Each prints as Chrome's print composites it inside the layer's tiles:source-inkeeps the layer where those below are opaque,source-outanddestination-outcut it out of them,clearclears its tiles, andxorandplus-lighterdraw assource-over.
Images and forms
object-fit and object-position place an <img>'s picture in its content box as Chrome places it, for a raster image and for an SVG file drawn as vectors alike. appearance is read for one thing: whether a form control keeps the native look daeepdf draws for it. The controls themselves become form fields in the PDF (see fillable).
object-fitFits an
<img>'s picture into its content box as Chrome fits it:fill,contain,cover,noneorscale-down.The picture is sized from its natural size against the content box, inside any padding and border, and cut to the content box where it overflows, the corners following
border-radius. Every value prints as Chrome's print draws it, for a raster image and an SVG file alike; an SVG is drawn as vectors in the box it's fitted to where daeepdf can draw it whole (see the SVG area).object-positionPlaces the fitted picture in its content box, at its center by default, as Chrome places it.
Keywords, lengths, percentages and the four-value form, such as
right 10px bottom, resolve against the room the box leaves around the picture, so100% 100%puts it in the bottom right corner, and withcoverornonethe picture is cut on the sides it overflows. It moves nothing withfill, which leaves no room.appearancenoneturns off the native look daeepdf draws for a form control, its check mark too, as Chrome's print does.Chrome draws an
<input>,<button>,<select>or<textarea>with a native look until you give it a border or a background, and daeepdf draws its own likeness of it: a 1px gray border with 2px corners, and a gray square or circle for a checkbox or radio button.appearance: noneturns that off, so the control prints its own CSS box only, as Chrome draws it.-webkit-appearanceis the same property in Chrome.The controls are still form fields. A checked checkbox or radio button with its native look prints daeepdf's own check mark, a stroke in the control's text color, with
fillable: falsetoo, where Chrome's print draws its blue one. Underappearance: nonethe field draws nothing of its own, so a custom checkbox, one that fills itself when checked, prints as its CSS paints it; its value is still the form's.
SVG
An inline <svg> or an SVG image goes into the PDF as vector paths when daeepdf can draw all of it, and otherwise as one image at 216 dpi that Chrome draws, the image path. Shapes, their geometry, fills, strokes and plain gradients are drawn as vectors; text, markers, clip paths, filters and masks send the whole SVG to the image path, where its text is pixels. Each entry says which. In an inline <svg>, what the page's stylesheet sets counts: daeepdf writes each element's computed values onto a copy of the SVG before it converts it.
fillFills a shape as a vector: a color,
currentColor,noneor a plain gradient; other paint sends the SVG to the image path.A color in any CSS form, translucent ones included, or
currentColor, resolved against the shape's owncolor, fills the shape as a vector path.url(#id)naming a<linearGradient>or<radialGradient>is a vector shading when the gradient has two stops or more of its own, works inobjectBoundingBoxunits, pads past its ends and takes nothing throughhref. A gradient inuserSpaceOnUseunits, one that repeats or reflects, one built throughhrefas design tools export it, a radial one turned against the page, or a<pattern>sends the whole SVG to the image path. A<line>has no fill.In an inline
<svg>, a fill set by the page's stylesheet counts, and an icon filled withcurrentColortakes its color from the page, as in Chrome.fill-opacityMultiplies a shape's fill alpha, as a vector fill's opacity.
A number or a percentage, clamped to 0 to 1, multiplies the fill color's own alpha and the opacity of the shape and its groups, and the result is the fill's opacity in the PDF. On a gradient fill it fades the whole shading.
fill-rulenonzeroorevenodd, the PDF's two fill rules, for a vector fill.A shape whose path crosses itself, or a path with a hole such as a ring, fills as Chrome fills it under either rule. The rule of a
clip-path: polygon()orpath()on an HTML box is written in the shape instead.strokeStrokes a shape as a vector in a color,
currentColorornone; a gradient stroke sends the SVG to the image path.A color, translucent or not, or
currentColordraws a vector stroke, with the width, dashes, caps and joins the otherstroke-properties give it. A stroke of no width draws nothing. A stroke with a gradient or a pattern sends the whole SVG to the image path, where Chrome draws it.stroke-widthThe stroke's width in user units, scaled with the shape, for a vector stroke.
Numbers and px, in, cm, mm, Q, pt and pc lengths are read, a percentage is of the viewport's normalized diagonal, and 0 draws no stroke. In an SVG file, a width in
em,vwor another relative unit, or acalc(), sends the SVG to the image path; in an inline<svg>, Chrome has already resolved it to px.The width scales with the shape's transforms and the
viewBox, as Chrome scales it. Under a scale that differs by axis, such as aviewBoxstretched withpreserveAspectRatio="none"or askewX(), the stroke stretches with the shape, wider along the stretched axis, its dashes too: daeepdf draws it in the shape's own units under its transform, as Chrome does.stroke-opacityMultiplies a stroke's alpha, kept apart from the fill's in the PDF.
A number or a percentage, clamped to 0 to 1, multiplies the stroke color's own alpha and the opacity of the shape and its groups. A shape whose fill and stroke differ in opacity draws each at its own, as Chrome draws it.
stroke-dasharrayDashes a vector stroke, its lengths in user units scaled with the shape.
A list of numbers and lengths, separated by spaces or commas, sets the dashes and gaps, scaled as the width is.
none, or a list of zeros, draws a solid stroke, and a negative length makes the list invalid, so the inherited one stays, as in Chrome. A circle's or ellipse's dashes start at 3 o'clock and run clockwise, as SVG draws them.A shape with a
pathLength, or in an SVG file a list holding a word, a relative unit orcalc(), sends the SVG to the image path, where Chrome draws the dashes.stroke-dashoffsetShifts where a vector stroke's dash pattern starts, in user units scaled with the shape.
A number or a length is read as
stroke-widthreads one, and in an SVG file a relative unit or acalc()sends the SVG to the image path.stroke-linecapbutt,roundorsquarecaps on a vector stroke, the PDF's own.They print as Chrome draws them, on the ends of open paths and of each dash.
stroke-linejoinmiter,roundorbeveljoins on a vector stroke, the PDF's own.They print as Chrome draws them; a
miterjoin paststroke-miterlimitis beveled.stroke-miterlimitHow long a miter join may grow before it is beveled, 4 by default, written into a vector stroke.
A number of at least 1, a multiple of the stroke's width, as in SVG and in the PDF. A value under 1, or one with a unit, keeps the inherited limit.
paint-orderPuts a stroke under its fill, as Chrome paints it, on SVG shapes and on stroked HTML text.
With the stroke before the fill, as in
paint-order: stroke, the stroke paints first and the fill over it, so a wide stroke shows only its outer half. An SVG drawn as vectors draws the two as separate paths in that order, in an inline<svg>and an SVG file alike, and the value inherits, so a group's order reaches its shapes. On the image path, an SVG with text or markers, Chrome draws it.HTML text with
-webkit-text-strokedraws its stroke from the glyphs' outlines, under the text, which stays text. In vertical text, or where a font's outlines can't be read, the stroke stays over the fill.vector-effectnon-scaling-strokekeeps a stroke's width and dashes in CSS px, whatever the shape's scale.The stroke is drawn as wide as its
stroke-widthin CSS px of the page, its dashes too, through anyviewBoxand transform, as a vector stroke, and as wide on the image path and in an SVG mask.none, the default, scales them with the shape.stop-colorA gradient stop's color, read for a vector shading;
currentColortakes the stop's owncolor.Set as an attribute, in a style attribute or, in an inline
<svg>, by the page's stylesheet, it is read for each<stop>of a gradient daeepdf draws as a vector (seefill), in any CSS color form. A stop whose offset is below the one before it takes that one's, as SVG says. An SVG gradient mixes its colors straight, not premultiplied, as Chrome mixes them.stop-opacityScales a gradient stop's alpha, for a vector shading.
A number or a percentage multiplies the alpha of
stop-color, sotransparentstays black at 0 alpha and a stop at 0.3 fades the shading toward it, as Chrome draws it.clip-ruleRead only on the image path: a
<clipPath>sends its SVG there, where Chrome applies the rule.clip-ruleapplies to the shapes inside a<clipPath>, and any<clipPath>in an SVG sends the whole SVG to the image path at 216 dpi, so it prints as Chrome draws it, as pixels. In an inline<svg>, a value the page's stylesheet sets is written onto the copy Chrome draws.The rule of a
clip-path: polygon()orpath()on an HTML box is written in the shape instead.marker-startRead only on the image path: an SVG with markers goes in as an image, where Chrome draws them.
Draws a marker at the first vertex of a path, line, polyline or polygon. A PDF path has no markers, so any
<marker>in an SVG, or one it references from elsewhere in the page, which daeepdf copies in, sends the whole SVG to the image path at 216 dpi, and the markers print as Chrome draws them, as pixels. A reference to an id that doesn't exist draws no marker and leaves the SVG as vectors.marker-midRead only on the image path: an SVG with markers goes in as an image, where Chrome draws them.
Draws a marker at each vertex between the first and the last. A PDF path has no markers, so any
<marker>in an SVG, or one it references from elsewhere in the page, which daeepdf copies in, sends the whole SVG to the image path at 216 dpi, and the markers print as Chrome draws them, as pixels. A reference to an id that doesn't exist draws no marker and leaves the SVG as vectors.marker-endRead only on the image path: an SVG with markers goes in as an image, where Chrome draws them.
Draws a marker at the last vertex of a path, line, polyline or polygon. A PDF path has no markers, so any
<marker>in an SVG, or one it references from elsewhere in the page, which daeepdf copies in, sends the whole SVG to the image path at 216 dpi, and the markers print as Chrome draws them, as pixels. A reference to an id that doesn't exist draws no marker and leaves the SVG as vectors.dA
<path>'s path data, from the attribute or the CSSdproperty, drawn as a vector path.The CSS property takes
path("..."), from a stylesheet in an inline<svg>or a style attribute in an SVG file, and wins over the attribute;nonedraws nothing. Path data is read as Chrome reads it, up to its first error, and the attribute takes path data alone, sod="path(...)"draws nothing, as in Chrome.xThe left of a
<rect>, and the x offset of what a<use>draws, read for a vector path.A number, a px, in, cm, mm, Q, pt or pc length, or a percentage of the viewport's width, from the attribute or CSS. In an inline
<svg>a value the page's stylesheet sets is resolved and written onto daeepdf's copy, and in an SVG file a relative unit such asemsends the SVG to the image path. An<image>, a nested<svg>and a<foreignObject>go to the image path anyway, where Chrome places them.yThe top of a
<rect>, and the y offset of what a<use>draws, read for a vector path.Read as
xis, a percentage of the viewport's height. An<image>, a nested<svg>and a<foreignObject>go to the image path anyway, where Chrome places them.cxThe x of a
<circle>'s or<ellipse>'s center, read for a vector path.Read as
xis, from the attribute or CSS, a percentage of the viewport's width.cyThe y of a
<circle>'s or<ellipse>'s center, read for a vector path.Read as
yis, from the attribute or CSS, a percentage of the viewport's height.rA
<circle>'s radius, read for a vector path; 0 draws nothing.Read as
xis, from the attribute or CSS; a percentage is of the viewport's normalized diagonal, its diagonal over the square root of 2.rxAn
<ellipse>'s x radius, or a<rect>'s corner radius along x, read for a vector path.Read as
xis. On a<rect>, an absent orautoradius takesry's, and each is cut to half the side; on an<ellipse>, 0 draws nothing.ryAn
<ellipse>'s y radius, or a<rect>'s corner radius along y, read for a vector path.Read as
yis. On a<rect>, an absent orautoradius takesrx's, and each is cut to half the side; on an<ellipse>, 0 draws nothing.text-anchorRead only on the image path: SVG text always goes in as an image, where Chrome aligns it.
start,middleandendprint as Chrome aligns them, since daeepdf doesn't convert SVG text to vectors or to PDF text: any<text>,<tspan>or<textPath>sends the whole SVG to the image path at 216 dpi, drawn by Chrome in the template's own fonts. The text is pixels there, so it can't be selected or searched and isn't in the PDF's text, where Chrome's print keeps it as text.In an inline
<svg>, a value the page's stylesheet sets is written onto the copy Chrome draws.import pdf from 'daeepdf' const html = `<style> @font-face { font-family: Inter; src: url('/fonts/inter-var.ttf'); } body { font: 12pt Inter; } </style> <svg width="200" height="60" viewBox="0 0 200 60"> <text x="100" y="35" text-anchor="middle" font-family="Inter" font-size="16">Quarterly sales</text> </svg> <p>Below the chart</p>` const file = await pdf.render(html) // The SVG prints as an image: its label shows, but isn't in the PDF's text.dominant-baselineRead only on the image path: SVG text always goes in as an image, where Chrome sets its baseline.
It prints as Chrome sets it, since daeepdf doesn't convert SVG text to vectors or to PDF text: any
<text>,<tspan>or<textPath>sends the whole SVG to the image path at 216 dpi, drawn by Chrome in the template's own fonts. The text is pixels there, so it can't be selected or searched and isn't in the PDF's text, where Chrome's print keeps it as text.alignment-baselineRead only on the image path: SVG text always goes in as an image, where Chrome aligns it.
It prints as Chrome aligns it, since daeepdf doesn't convert SVG text to vectors or to PDF text: any
<text>,<tspan>or<textPath>sends the whole SVG to the image path at 216 dpi, drawn by Chrome in the template's own fonts. The text is pixels there, so it can't be selected or searched and isn't in the PDF's text, where Chrome's print keeps it as text.baseline-shiftRead only on the image path: SVG text always goes in as an image, where Chrome shifts it.
sub,superand lengths print as Chrome shifts them, since daeepdf doesn't convert SVG text to vectors or to PDF text: any<text>,<tspan>or<textPath>sends the whole SVG to the image path at 216 dpi, drawn by Chrome in the template's own fonts. The text is pixels there, so it can't be selected or searched and isn't in the PDF's text, where Chrome's print keeps it as text.flood-colorRead only on the image path: a
<filter>sends its SVG there, where Chrome floods with it.It colors
<feFlood>and<feDropShadow>, and any<filter>in an SVG sends the whole SVG to the image path at 216 dpi, so it prints as Chrome draws it, as pixels. In an inline<svg>, a value the page's stylesheet sets is written onto the copy Chrome draws.flood-opacityRead only on the image path: a
<filter>sends its SVG there, where Chrome applies it.It fades
<feFlood>and<feDropShadow>, and any<filter>in an SVG sends the whole SVG to the image path at 216 dpi, so it prints as Chrome draws it, as pixels. In an inline<svg>, a value the page's stylesheet sets is written onto the copy Chrome draws.lighting-colorRead only on the image path: a
<filter>sends its SVG there, where Chrome lights with it.It colors
<feDiffuseLighting>and<feSpecularLighting>, and any<filter>in an SVG sends the whole SVG to the image path at 216 dpi, so it prints as Chrome draws it, as pixels. In an inline<svg>, a value the page's stylesheet sets is written onto the copy Chrome draws.