Feature Library

Files out with no library: PDF from pictures, SVG from shapes

<0.01 CPU ms
A still of the Files out with no library: PDF from pictures, SVG from shapes demo
Still
The live demo starts when it’s in view.Pick a sample or drop a CSV, an .xlsx or a zip · the page and its PDF follow · save either

Writes the files an app hands people, in plain TypeScript.

What it costs a frame

<0.01 ms
GPU
not used
CPU, median
<0.01 ms
CPU, 95th pct
0.01 ms
Draw calls
0
Weight
Light

Measured 13 November 2026 on RTX 4060 Laptop, 13th Gen Intel(R) Core(TM) i9-13900H, Chrome 157, 1920×1080 at 1×. 600 frames × 3 rounds, median kept (rounds ranged CPU <0.01–<0.01 ms). What ran: Measured reading plants.csv and writing its page as SVG, a JPEG and a PDF, once every 1.5 s, from memory. Idle, nothing runs. Phones: tiers are being measured next.

On every machine it was measured on
MachineGPU msCPU msCPU p95
RTX 4060 Laptop · 13th Gen Intel(R) Core(TM) i9-13900Hreference · measuring toolnot timed<0.010.01
apple · Apple A19 Proin a browser tab · 16 November 2026not timed<0.010.02
Intel Arc 140V (Xe2-LPG) · Intel Core Ultra 7 258Vin a browser tab · 15 November 2026not timed<0.010.01

Bars against one 16.7 ms frame. A browser-tab run is timed in a visible tab without the tool’s scripted input, so read it as close, not exact.

What it needs

Renders with
DOM and CSSPlain DOM and CSS: every current browser.
Your browser
Runs hereNo WebGPU needed
Depends on
NothingNo other packages

What it’s for

  1. Exporting a board, chart or report as PDF and SVG
  2. Turning slides or screenshots into one PDF
  3. A PDF of photos taken on a phone, the right way up
  4. Telling a dropped file’s kind before reading it
  5. Saving files from a static site under a strict Content Security Policy
  6. Printable pages without a PDF library

Pitfalls, in brief

  1. A phone saves an upright photo on its side with an EXIF note to turn it.
  2. JPEG has no transparency: what is see-through on a canvas comes out black.
  3. A drawn page goes into the PDF as a picture: its text cannot be selected or searched.
  4. An SVG drawn onto a canvas through an image sees no web fonts and loads nothing from outside itself: use a system font stack, and embed pictures as data: URLs.
  5. Don’t make blob: URLs for pictures under a strict Content Security Policy (img-src 'self' data:): show bytes as data: URLs (dataUrl) and decode them with createImageBitmap.
5 more in brief
  1. Lossless and arithmetic-coded JPEGs can’t go into a PDF as they are; jpegInfo refuses them with a reason rather than writing a page no reader shows.
  2. Adobe software stores CMYK JPEGs inverted: pdf.ts adds the Decode array when it finds Adobe’s APP14 block.
  3. Every value written into SVG must be escaped, attribute values too: a colour or a URL from user data can otherwise close the attribute and add its own. toSvg also drops what XML can’t hold (control characters, and half an emoji from a string cut short): one such character made the whole file unreadable.
  4. Tell a file by its first bytes, not its name: a .csv may be an Excel file saved under the wrong name, and an .xlsx is a zip whose kind shows only in the names inside it (zipKind).
  5. Vite inlines small files (under 4 kB by default) as data: URLs; a fetch of one breaks under connect-src 'self'.
10 pitfalls in full, the hook-up guide, the module source and its tests come with the part.

Where it comes from

From SpaciousPro. Fully custom code.

ISO 32000 (PDF) and the PDF 1.4 Reference (Adobe): objects, the cross-reference table, image XObjects with the DCTDecode filter, the CTM and text strings in UTF-16BE

ITU-T T.81 (JPEG) and JFIF: the markers and frame header read by jpegInfo

Exif 2.3 (CIPA DC-008) and TIFF 6.0: the orientation tag (0x0112) and its eight values

W3C SVG 1.1: the parts toSvg writes

George Marsaglia, “Xorshift RNGs” (2003): xorshift32 makes the demo’s big CSV

pdfsvgjpegexiforientationexportdownloadfile sniffingmagic byteszipxlsxcsvdrag and dropprinta4cspno dependencies

Near it in the frame