Top
Best
New

Posted by lulzx 5 days ago

Show HN: TinyPDF – 3kb pdf library (70x smaller than jsPDF)(github.com)
I needed to generate invoices in a Node.js app. jsPDF is 229KB. I only needed text, rectangles, lines, and JPEG images.

  So I wrote tinypdf: <400 lines of TypeScript, zero dependencies, 3.3KB minified+gzipped.

  What it does:
  - Text (Helvetica, colors, alignment)
  - Rectangles and lines
  - JPEG images
  - Multiple pages, custom sizes

  What it doesn't do:
  - Custom fonts, PNG/SVG, forms, encryption, HTML-to-PDF

  That's it. The 95% use case for invoices, receipts, reports, tickets, and labels.

  GitHub: https://github.com/Lulzx/tinypdf
  npm: npm install tinypdf
251 points | 32 commentspage 2
userbinator 4 days ago|
I still have a tiny DOS binary (x86 Asm) that I wrote decades ago for turning plaintext ASCII files into PDFs, for those annoying use-cases where the former isn't accepted but the latter is. It's only a few hundred bytes, with the majority being data to be copied verbatim into the output file.
dzrmb 4 days ago||
I actually was battling jsPDF the other day so definitely need to give this a try, thanks!
nanis 4 days ago||
HTML + CSS works great for this kind of thing. Once you get the print scope correct, you really never need to think about it again.
winterec 4 days ago||
Great work thanks for sharing. I've been looking for something like this for generating invoice PDFs without bloat.
ErroneousBosh 4 days ago||
Heh, no stars when I first looked and though "hey I'll star this" and now 300 ;-)
alexpadula 4 days ago||
Well ain’t that a useful 400 lines of code eh! Good work
croisillon 4 days ago|
is it related to one of the other 10 products called TinyPDF?
esafak 4 days ago|
Yes, obviously: it's a tiny PDF library.