PDF

Turn any PDF into a flipbook.

Install

PDF support is a small add-on package so you only pull it in when you need it.

pnpm add @zinejs/core @zinejs/pdf pdfjs-dist

PdfSource

Pass a URL (or bytes). Under most bundlers the worker is auto-resolved with no config required for the common case.

import { Zine } from '@zinejs/core';
import { PdfSource } from '@zinejs/pdf';

const book = new Zine(document.getElementById('book'), {
  source: new PdfSource('/catalog.pdf'),
});

Options

// Vite / Nuxt: resolve the worker via ?url
import pdfWorker from 'pdfjs-dist/build/pdf.worker.min.mjs?url';

new PdfSource('/catalog.pdf', {
  workerSrc: pdfWorker,
  renderScale: 1,
  preload: 1,
});
  • workerSrc: optional; auto-resolved under Vite/webpack
  • renderScale: base raster scale (default 1)
  • preload: neighbor pages to prefetch
  • maxCacheBytes: LRU cache cap (default ~256 MB)

See the PDF example.