Skip to content

ranasl62/libraries

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Laru

Laru is an open-source HTML-to-PDF solution: fast, robust, and efficient — one native render pass, no page limit, streams to file for maximum PDF generation. Full control via a rich options API (timeout, retry, waitForSelector, margins, scale, page range, PDF metadata, and more).

Packages

Package Purpose
laru-pdf-js JS library: shared API and types. In the browser, methods reject with guidance to use native or Print → Save as PDF.
laru-cap-pdf Capacitor (cap) plugin: native iOS/Android HTML→PDF. Uses WebKit/WebView (no canvas).

Quick start

In a Capacitor (Ionic) app (native iOS/Android):

npm install laru-cap-pdf
npx cap sync
import { LaruCapPdf } from 'laru-cap-pdf';
const { path } = await LaruCapPdf.fromData({
  data: '<h1>Hello</h1>',
  type: 'file',
  fileName: 'out.pdf',
  baseUrl: 'file:///android_asset/',  // when HTML has relative CSS/JS
});

In a web-only project:

npm install laru-pdf-js

Same API; in the browser it will throw with a message to use Print → Save as PDF or use the cap plugin in a native app.

Why Laru is better than the market

  • Faster than html2pdf / jsPDF / canvas2pdf — One native WebKit/WebView render pass; no per-page canvas or bitmap. Same document in a fraction of the time.
  • 500+ pages — Native formatters paginate in one pass; use type: 'file' for large docs. Canvas-based libs typically choke or run out of memory.
  • Full CSS/JS — Pass baseUrl so relative styles, scripts, and images resolve. All options (timeout, waitForSelector, margins, printBackground, httpHeaders, metadata) are implemented.
  • Open source, you own it — MIT. No vendor or paid-tier lock-in.
  • Same API everywhere — laru-pdf-js (web) and laru-cap-pdf (native) share the same HtmlToPdfOptions and methods.
  • Every option you’d expect — page size (preset + custom), margins + presets, scale/fitToPage, pageRange, header/footer HTML, viewport, userAgent, preferColorScheme, mediaType, runBeforePrint, injectStyles, timeout, waitForSelector, PDF metadata, and more. See laru-cap-pdf options.

See laru-cap-pdf for why Laru has no page/timeout/scale limits like the market.

Development and testing

  • laru-pdf-js: npm run build then npm test (Vitest; validation and API behavior).
  • laru-cap-pdf: npm run build then npm test (Vitest; web validation). Use npm install --legacy-peer-deps if laru-pdf-js is not published yet.

License

MIT

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors