Repolode
Lulzx

Lulzx/tinypdf

Minimal zero-dependency TypeScript library for generating real PDF files with text, rectangles, lines, JPEG images and links.

Stars
1,923
Forks
76
Open issues
0
Last commit
2 months ago

What is it?

tinypdf is a small PDF creation library for TypeScript and JavaScript. It has no dependencies and is under 400 lines of code, at about 3.3 KB. It deliberately leaves out custom fonts, PNG/SVG, forms, encryption and HTML-to-PDF conversion, focusing on putting text and images on a page.

Documents are built with a callback-based API: you create a page, draw text, rectangles, lines, JPEG images and clickable links on it, then call build() to get a Uint8Array or buildStream() to get a ReadableStream for large files. A markdown() helper converts simple markdown with headers, lists and rules into a paginated PDF, and measureText() returns text width in points.

The project suits generating invoices, receipts, reports, tickets and certificates where the layout is fixed and Helvetica text is sufficient. For Unicode fonts or more complex PDF features, the README points to jsPDF or pdf-lib.

Key features

  • 01Draws text in Helvetica with custom size, hex color and alignment.
  • 02Adds filled rectangles, lines and JPEG images to pages.
  • 03Creates clickable links with optional underline.
  • 04Supports multiple pages with custom sizes.
  • 05Converts simple markdown into a paginated PDF.
  • 06Streams large documents through buildStream().

Use cases

  • Generating invoices and receipts with a fixed layout.
  • Producing event tickets or certificates with logos and signatures.
  • Exporting data reports as PDF from a Node, Bun or server-side JavaScript app.
  • Serving PDFs as HTTP responses without adding heavy dependencies.

Quick start

  1. 1

    Install the package from npm

    npm install tinypdf
  2. 2

    Import pdf, create a document, add a page with text and shapes, then write the file

  3. 3

    Run any example with Bun

    bun examples/executive-report.ts

Things to know

  • Text uses only the built-in Helvetica font with WinAnsi encoding; no Unicode or custom fonts.
  • Images must be JPEG; PNG, GIF and SVG are not supported.
  • Features such as forms, encryption, compression and HTML-to-PDF are not included.

Topics

FAQ

What is tinypdf?
Minimal zero-dependency TypeScript library for generating real PDF files with text, rectangles, lines, JPEG images and links. tinypdf is a small PDF creation library for TypeScript and JavaScript. It has no dependencies and is under 400 lines of code, at about 3.3 KB. It deliberately leaves out custom fonts, PNG/SVG, forms, encryption and HTML-to-PDF conversion, focusing on putting text and images on a page.
Is tinypdf free to use? What license does it have?
tinypdf is open source under the MIT license. Check the license terms before using it in commercial products.
Is tinypdf still maintained?
Updated within 6 months. The last commit to tinypdf was on Aug 13, 2026.
What can I use tinypdf for?
Generating invoices and receipts with a fixed layout. Producing event tickets or certificates with logos and signatures. Exporting data reports as PDF from a Node, Bun or server-side JavaScript app. Serving PDFs as HTTP responses without adding heavy dependencies.
How do I install tinypdf?
Install the package from npm: npm install tinypdf Import pdf, create a document, add a page with text and shapes, then write the file Run any example with Bun: bun examples/executive-report.ts
Where can I get tinypdf?
The source code and installation instructions are on GitHub: https://github.com/Lulzx/tinypdf

Summary generated by AI from the project's README. GitHub stats refresh daily.

Related projects