Skip to content

Latest commit

 

History

History
78 lines (60 loc) · 3.63 KB

README.md

File metadata and controls

78 lines (60 loc) · 3.63 KB

DocSpring HTML designs

17 print document designs from DocSpring's template library, as standalone HTML with their fonts and made-up sample data. They're laid out the way people build documents for print: CSS grid, running headers and footers, "Page 1 of 3" counters, page breaks, tables that span pages, and form fields. That makes them a good test set for an HTML-to-PDF engine.

We used them in a case study to show that seven of these designs crash WeasyPrint 67.0 to 69.0, which WeasyPrint's own samples never showed.

Design Design Design
01 invoice 07 quote 13 letter
02 certificate 08 report 14 timesheet
03 badge 09 shipping label 15 gift certificate
04 receipt 10 membership card 16 application form
05 packing slip 11 payslip 17 purchase order
06 ticket 12 transcript

Each design's folder holds two documents:

  • data.html: the design with short sample data. Most designs fit on one page.
  • data-long.html: the same design with long values, many rows and empty optional fields, which runs most designs onto several pages.

The fonts are in fonts/, loaded with @font-face by relative path, so each file renders as it is. Images (logos, QR codes, barcodes, charts) are data: URLs inside the HTML.

Render them

With WeasyPrint, from a design's folder:

weasyprint data.html data.pdf
weasyprint data-long.html data-long.pdf

Add --pdf-forms for 07, 14 and 16 to keep their form fields fillable.

CSS they rely on

It's all standard CSS, with no vendor prefixes or custom properties, but print engines support some of it unevenly:

Feature Where
Running headers and footers: position: running() with content: element() in @top-center / @bottom-center 01, 05, 07, 08, 11, 12, 13, 14, 16, 17
counter(page) and counter(pages) inside the running header or footer 01, 05, 07, 08, 12, 13, 14, 16, 17
display: grid with explicit rows, columns and gaps every design
display: flex every design except 10
break-inside: avoid, break-after: avoid and break-after: page the multi-page designs
position: absolute inside fixed-size overflow: hidden boxes every design
position: fixed SVG watermark on every page 07 (data), 01 (data-long)
object-fit and object-position on images every design except 08 and 14
columns with column-rule 17
table-layout: fixed, <colgroup>, border-collapse the table designs
Inline SVG with <clipPath> and <text> 08
<input>, <select>, <textarea> 07, 14, 16

Some text boxes in 02, 03, 06, 09, 10 and 15 shrink their text to fit in DocSpring's PDFs. That isn't CSS, so here they keep their starting font size, and long text in them can overflow or be clipped.

Licence

The HTML is MIT licensed (see LICENSE). The sample data is made up.

The fonts in fonts/ aren't covered by the MIT licence. Each keeps its own, in the file next to it:

Font Licence File
Great Vibes SIL Open Font License 1.1 GreatVibes-OFL.txt
Lato SIL Open Font License 1.1 Lato-OFL.txt
Liberation Sans SIL Open Font License 1.1 LiberationSans-LICENSE.txt
Liberation Serif SIL Open Font License 1.1 LiberationSerif-LICENSE.txt
Open Sans Apache License 2.0 OpenSans-LICENSE.txt
Poppins SIL Open Font License 1.1 Poppins-OFL.txt
Public Sans SIL Open Font License 1.1 PublicSans-OFL.txt
Roboto Apache License 2.0 Roboto-LICENSE.txt
Roboto Mono Apache License 2.0 RobotoMono-LICENSE.txt