PDF.js 4.0 is a major release that contains a number of API changes, features and bugfixes. The following changes are highlighted:
- Conversion to JavaScript modules for the builds
- Conversion to Fluent for localization
- Optimizations for CPU and memory usage
- Improvements and bugfixes for the annotation editor and annotation rendering
- Removal of the deprecated SVG back-end
- Removal of other deprecated functionality and options
The complete list of changes in this release is shown below. If you're upgrading to PDF.js 4.0 we recommend checking the changes prefixed with [api-minor]
and [api-major]
since those might require updates to your code.
Changes since v3.11.174
- Bump the stable version in
pdfjs.config
by @timvandermeij in #17024 - [Editor] Slightly postpone the move in the DOM in order to not block the UI (bug 1854991) by @calixteman in #17031
- [Editor] Remove the class fooEditing from the layer when destroying it by @calixteman in #17030
- [Editor] Don't try to add data to the struct tree when there is no accessibilityData (bug 1855157) by @calixteman in #17034
- [Editor] Disabled the alt-text button when the editor is being resized by @calixteman in #17039
- [Editor] Remove unused CSS rules for the altText "Save"-button (PR 17015 follow-up) by @Snuffleupagus in #17040
- [Editor] Clear the different timeouts when destroying by @calixteman in #17041
- StructParents entry isn't required on pages with no tagged contents (bug 1855641) by @calixteman in #17043
- [Editor] Disable pointer events in the parent layer while an editor is resized by @calixteman in #17045
- Remove comments from the built CSS files by @Snuffleupagus in #17035
- Make downloadManager optional in JSDoc types by @ayushmourya in #17038
- Update Puppeteer to the latest version by @Snuffleupagus in #17027
- Convert
layerProperties
to an Object (PR 15811 follow-up) by @Snuffleupagus in #17026 - [Editor] Remove almost all the waitForTimeout from the freetext integration tests by @calixteman in #17036
- Remove the timeouts from the inkEditor integration tests by @calixteman in #17048
- Remove the timeouts from the stampEditor integration tests by @calixteman in #17049
- [Editor] Make a deleted (when it was invisible) editor undoable by @calixteman in #17050
- Use a standard
export
statement in theweb/pdfjs.js
file by @Snuffleupagus in #17052 - Add alt-text svg images to the dist (issue #17044) by @calixteman in #17053
- Fix new intermittent failures with ink and stamp tests by @calixteman in #17051
- [Editor] Don't show the alt-text button when the alt-text dialog is visible by @calixteman in #17032
- [Editor] Use the alt text to descibe the canvas used to display the image by @calixteman in #17058
- Remove timeouts from the copy_paste integration test by @calixteman in #17059
- [api-major] Remove various deprecated functionality and options by @Snuffleupagus in #16774
- [api-major] Remove the SVG back-end (PR 15173 follow-up) by @Snuffleupagus in #16699
- Ensure that readonly TextWidget-annotations are rendered when forms are disabled (issue 17064) by @Snuffleupagus in #17066
- Compute correctly the bounding box of a transformed rectangle (fixes #17065) by @calixteman in #17067
- Bump library version to
4.0
by @Snuffleupagus in #17063 - Add support for "GoToE" actions with destinations (issue 17056) by @Snuffleupagus in #17060
- [Editor] Support resizing editors with the keyboard (bug 1854340) by @calixteman in #17062
- [Editor] Add role=spinbutton to resizers when they're used with the keyboard by @calixteman in #17072
- Update the noHTML flag to take into account the hasOwnCanvas one (fixes #17069) by @calixteman in #17070
- Add a HTML containter for locked FreeText annotations in order to be able to display a popup (follow-up of #17070) by @calixteman in #17075
- Enable some Stylelint color-related rules to slightly reduce file sizes by @Snuffleupagus in #17076
- Make the toolbar buttons usable with keyboard when Page Fit is used by @calixteman in #17074
- [Editor] Add the possibility to create a new editor in using the keyboard (bug 1853424) by @calixteman in #16761
- Remove unnecessary alpha-value from CSS
rgb
colors by @Snuffleupagus in #17077 - [api-major] Output JavaScript modules in the builds (issue 10317) by @Snuffleupagus in #17055
- Output
pdf.scripting.js
as a JavaScript module (PR 17055 follow-up) by @Snuffleupagus in #17080 - [api-minor] Stop polyfilling
structuredClone
in legacy builds by @Snuffleupagus in #17086 - Activate the selector check for the
autoprint
integration test as soon as possible by @timvandermeij in #17090 - Bump postcss from 8.4.30 to 8.4.31 by @dependabot in #17093
- Rename
web/debugger.js
since it's actually a JavaScript module (PR 17055 follow-up) by @Snuffleupagus in #17094 - Fix the protocol timeout configuration for Puppeteer by @timvandermeij in #17095
- [Debugger] Add some info about substitution font by @calixteman in #17073
- Update the "Interactive examples" links (PR 17055 follow-up) by @Snuffleupagus in #17105
- Don't store page-level data, in the API, after cleanup has run (bug 1854145) by @Snuffleupagus in #17106
- Remove useless chrome.properties file (bug 1858700) by @calixteman in #17113
- Convert the
integration
test-files to JavaScript modules by @Snuffleupagus in #17112 - Output JavaScript modules for the
LIB
build-target (PR 17055 follow-up) by @Snuffleupagus in #17114 - Tweak
PDFWorkerUtil.createCDNWrapper
to account for JavaScript modules (PR 17055 follow-up) by @Snuffleupagus in #17098 - Use native
import maps
in development mode by @Snuffleupagus in #14743 - Enable the
import/no-commonjs
ESLint plugin rule by @Snuffleupagus in #17117 - Remove obsolete
src/shared/{cffStandardStrings,fonts_utils}.js
files by @timvandermeij in #17120 - Update translations/dependencies to the most recent versions and fix dependency vulnerabilities by @timvandermeij in #17119
- Remove Escape key press from the
autoprint
integration test, and tweak the protocol timeout configuration for Puppeteer by @timvandermeij in #17122 - Update the ESLint
globals
list (PR 17055 follow-up) by @Snuffleupagus in #17123 - Fix intermittent problems on Windows in the XFA search integration test by @timvandermeij in #17125
- Reduce unnecessary type conversion in
writeStream
by @Snuffleupagus in #17134 - Re-factor the blob-URL caching in
DownloadManager.openOrDownloadData
by @Snuffleupagus in #17131 - [api-minor] Move to Fluent for the localization (bug 1858715) by @calixteman in #17115
- Use a CSS-only solution to set the
dropdownToolbarButton
width (issue 17137) by @Snuffleupagus in #17138 - Only bundle
NullL10n
in GENERIC builds (bug 1859818) by @Snuffleupagus in #17135 - Try to make the
Preferences
/AppOptions
initialization slightly more efficient by @Snuffleupagus in #17130 - Use object destructuring, rather than the
merge
helper, in the gulpfile by @Snuffleupagus in #17133 - [L10n] Don't try to connect the root element when it has already been done by @calixteman in #17142
- Initialize the
L10n
-instance as soon as possible in Firefox (PR 17115 follow-up) by @Snuffleupagus in #17140 - Fix size of maskCanvas to draw image masks correctly by @JT-External in #17148
- Use a
ResizeObserver
to update the layout ofPDFFindBar
by @Snuffleupagus in #17152 - [api-minor] Re-factor
NullL10n
and remove the hard-coded l10n strings (PR 17115 follow-up) by @Snuffleupagus in #17146 - A couple of
PDFDocumentProperties
tweaks (PR 17115 follow-up) by @Snuffleupagus in #17151 - [api-minor] Use "data-l10n-id"/"data-l10n-args", rather than manually updating DOM-elements, to trigger translation (PR 17146 follow-up) by @Snuffleupagus in #17141
- Update the "aria-label" of the page when a
pageLabel
exists by @Snuffleupagus in #17156 - Update locale on *.ftl change by @calixteman in #17157
- [Annotation] Use the field V entry when there is no Parent one for a radio button (bug 1860602) by @calixteman in #17159
- Add a unit-test to ensure that
NullL10n
won't diverge from theL10n
-class by @Snuffleupagus in #17161 - Remove obsolete entries in the lint-ignore files by @Snuffleupagus in #17175
- Don't take into account the INVISIBLE flag for well-known annotations by @calixteman in #17171
- Update the path to get all locales and update locales by @calixteman in #17174
- Fix error that's breaking the
ConstL10n
class (PR 17161 follow-up) by @Snuffleupagus in #17173 - Slightly improve the performance of removeNullCharacters by @calixteman in #17165
- Remove the
enableStampEditor
preference by @Snuffleupagus in #17006 - Pause translation when appending the outline/attachment/layer trees to the sidebar by @Snuffleupagus in #17176
- Improve performance of optional content parsing by @calixteman in #17166
- Pause translation when appending the xfaLayer to the page by @Snuffleupagus in #17177
- Add workflow to lint Fluent en-US files by @flodolo in #17186
- Fix integration tests on Mac by @calixteman in #17189
- Use CSS nesting in the textLayer by @Snuffleupagus in #17195
- Use CSS nesting in the annotationLayer by @Snuffleupagus in #17196
- Fix
WidgetAnnotationElement._getKeyModifier
to account for Linux by @Snuffleupagus in #17185 - Update the GitHub Actions workflow for the Fluent linter by @timvandermeij in #17198
- Update the
examples/
-folder to account for outputting of JavaScript modules (PR 17055 follow-up) by @Snuffleupagus in #17081 - Handle appending consistently in the xfaLayer regardless of rendering intent (PR 17177 follow-up) by @Snuffleupagus in #17184
- Pause translation when appending the textLayer and structTreeLayer to the page by @Snuffleupagus in #17192
- Upgrade
setup-node
to version 4 in the GitHub Actions workflows by @timvandermeij in #17199 - Guard
navigator
-object accesses insrc/
-files (issue 15728) by @Snuffleupagus in #17153 - Update dependencies and translations to the most recent versions by @timvandermeij in #17203
- Fix the intermittent failures with PageOpen/PageClose test by @calixteman in #17205
- [Editor] Don't steal the keyboard events when editing mode is enabled by @calixteman in #17204
- [Firefox] Fetch browser preferences/options together with the viewer preferences (bug 1862192) by @Snuffleupagus in #17208
- Update the GitHub Actions workflows to use the current Node.js LTS version by @Snuffleupagus in #17201
- Render rich text with only one text element by @calixteman in #17216
- Update packages and translations by @Snuffleupagus in #17223
- Use even more optional chaining in the code-base by @Snuffleupagus in #17217
- Also test the latest Node.js version in GitHub Actions by @Snuffleupagus in #17202
- Re-factor how some API-options are handled in
PDFViewerApplication.open
(PR 17208 follow-up) by @Snuffleupagus in #17218 - Update
external/dist/webpack.js
to account for outputting of JavaScript modules (PR 17055 follow-up) by @Snuffleupagus in #17224 - Also pause translation when expanding the current outline-item (PR 17176 follow-up) by @Snuffleupagus in #17220
- Remove the
viewerCssTheme
-option, since it's partially broken by @Snuffleupagus in #17222