Skip to content

v4.5.0

Latest

Choose a tag to compare

@alekswebnet alekswebnet released this 07 Nov 15:38
· 1 commit to master since this release

Features

  • PDF.js 6.5.438, up from 6.4.299. This PDF.js release improves accessibility, annotation editing and rendering, font and image conversion, performance, scripting and the viewer. See the PDF.js release notes. (#77)

  • Drawing pages in a worker, and renderer-src. PDF.js 6.5 can draw pages in a second worker instead of on the main thread. PDF.js ships with it turned off. To turn it on, set the option before the viewer is built, for example on DOMContentLoaded:

    viewerElement.setViewerOptions({ disableWorkerRendering: false })

    The new renderer-src attribute sets the URL of that worker's script. It defaults to pdf.renderer.min.mjs next to the element, or inside assets-base, so you only need it when the file is served from somewhere else. The viewer's CSP allows the script's origin. If the worker can't start, PDF.js logs a "Renderer worker disabled" warning and draws on the main thread. See demo/worker-rendering.html. (#77)

Fixes

  • The open() parameter type no longer includes Uint8Array. PDF.js rejects bare bytes at runtime with getDocument - expected either `data`, `range`, or `url` parameter. TypeScript now reports the mistake at compile time. Pass { data: bytes } instead. (#76, #79)

Upgrading

There are no breaking changes, and worker rendering stays off unless you turn it on.

  • A worker-src pinned to a pdfjs-dist version, such as a CDN URL with pdfjs-dist@6.4.299, must move to 6.5.438. PDF.js refuses a worker from another version with The API version "6.5.438" does not match the Worker version "6.4.299".
  • A copy of dist served with assets-base must be replaced with this release's dist, as with every release. The copy now includes pdf.renderer.min.mjs (175 kB), which loads only when worker rendering is on.
  • TypeScript code that passed a Uint8Array to open() no longer compiles. Wrap the bytes as { data }. The old call already failed at runtime.

For contributors

  • Four tests passed even when the feature they cover was broken: the render, wrong-URL, base64 and shipped-resources tests. Each now fails when its feature breaks. No test depends on a PDF that exists only on one machine. (#76, #79)
  • Development dependencies updated: Vitest 5.1.0 and @types/node 26.6.6. (#74)

Full changelog: v4.4.2...v4.5.0