Commit Graph

14966 Commits

Author SHA1 Message Date
Jonas Jenwald
ff9d2b2ab1 Prevent run-time errors in Node.js versions with URL.createObjectURL support (issue 14170)
Apparently Node.js has added *global* `URL.createObjectURL` support, but not done the same thing for `Blob`. Hence we also need to check for the availability of `Blob` in the `createObjectURL` helper function, and it's probably a good idea to also update `examples/node/pdf2svg.js` to work-around this until these changes reach an official PDF.js release.
2021-10-21 10:32:44 +02:00
Jonas Jenwald
7c9e5781fe
Merge pull request #14159 from stbensonimoh/convert-example-to-async-await
Convert examples/node/pdf2svg.js to await/async #14125
2021-10-21 10:30:02 +02:00
Benson Imoh,ST
0643ccb68b
Convert examples/node/pdf2svg.js to await/async #14125 2021-10-20 21:51:58 +01:00
Tim van der Meij
382be22c11
Merge pull request #14160 from Snuffleupagus/pr-13770-followup
Fix pattern handling regression in `SVGGraphics` (PR 13770 follow-up)
2021-10-19 19:31:18 +02:00
Tim van der Meij
ce86f9dfdd
Merge pull request #14155 from mozilla/revert-13314-color-theme
Revert "For mozcentral use Firefox color theme instead of system theme." since `-moz-toolbar-prefers-color-scheme` was removed
2021-10-19 19:29:20 +02:00
Tim van der Meij
0fe358f7d6
Merge pull request #14154 from Snuffleupagus/update-packages
Update packages and translations
2021-10-19 19:26:08 +02:00
Brendan Dahl
b66239d6dc
Merge pull request #14114 from Snuffleupagus/issue-14110
[api-minor] Include the /Lang-property in the `documentInfo`, and use it in the viewer (issue 14110)
2021-10-19 08:08:08 -07:00
Jonas Jenwald
81eafcbd5f
Merge pull request #14166 from Snuffleupagus/issue-14164
Ignore Square/Circle-annnotations with a zero borderWidth when creating a fallback appearance stream (issue 14164)
2021-10-19 16:32:59 +02:00
Jonas Jenwald
68e6622c57 Ignore Square/Circle-annnotations with a zero borderWidth when creating a fallback appearance stream (issue 14164)
Trying to render these Annotation-types, when the borderWidth is `0`, causes a "hairline" border to appear. If these Annotations included an appearance stream, as they are supposed to, this wouldn't have happened and the simplest solution here seem to be to just ignore these particular Annotations.
2021-10-19 15:27:42 +02:00
Jonas Jenwald
8c6f1e45c7 Fix pattern handling regression in SVGGraphics (PR 13770 follow-up)
While the FAQ clearly lists the SVG back-end as unsupported, see https://github.com/mozilla/pdf.js/wiki/Frequently-Asked-Questions#backends, I suppose that small/simple regressions still makes sense to fix.
2021-10-18 21:40:10 +02:00
calixteman
bbb64369f1
Merge pull request #13424 from calixteman/chunks2
[api-minor] Fix issues in text selection
2021-10-18 06:14:15 -07:00
Calixte Denizet
61d1063276 Fix issues in text selection
- PR #13257 fixed a lot of issues but not all and this patch aims to fix almost all remaining issues.
  - the idea in this new patch is to compare position of new glyph with the last position where a glyph has been drawn;
    - no space are "drawn": it just moves the cursor but they aren't added in the chunk;
    - so this way a space followed by a cursor move can be treated as only one space: it helps to merge all spaces into one.
  - to make difference between real spaces and tracking ones, we used a factor of the space width (from the font)
    - it was a pretty good idea in general but it fails with some fonts where space was too big:
    - in Poppler, they're using a factor of the font size: this is an excellent idea (<= 0.1 * fontSize implies tracking space).
2021-10-17 16:27:05 +02:00
Jonas Jenwald
aae8a21286 Revert "For mozcentral use Firefox color theme instead of system theme." since -moz-toolbar-prefers-color-scheme was removed
Reverts mozilla/pdf.js#13314, see https://groups.google.com/g/firefox-dev/c/vajhbYKDpPM

Given that `-moz-toolbar-prefers-color-scheme` was removed in https://bugzilla.mozilla.org/show_bug.cgi?id=1736038, unless we fix this before the next PDF.js update in mozilla-central we'll thus break dark mode in the Firefox built-in PDF Viewer.
2021-10-17 12:29:25 +02:00
Jonas Jenwald
ee800a064a Update l10n files 2021-10-17 11:49:08 +02:00
Jonas Jenwald
b0affcd87c Fix (some) vulnerabilities reported by npm audit
This was done automatically, using the `npm audit fix` command.
2021-10-17 11:47:09 +02:00
Jonas Jenwald
a712b601ee Update ESLint to version 8
Please refer to https://eslint.org/docs/8.0.0/user-guide/migrating-to-8.0.0

Given that this is a major version increase it also required updating ESLint plugins, see https://github.com/sindresorhus/eslint-plugin-unicorn/releases and https://github.com/jrdrg/eslint-plugin-sort-exports/releases
2021-10-17 11:42:09 +02:00
Jonas Jenwald
7746732934 Update the stylelint-config-prettier package to the latest version
Please refer to https://github.com/prettier/stylelint-config-prettier/releases
2021-10-17 11:37:40 +02:00
Jonas Jenwald
decd585579 Update npm packages 2021-10-17 11:33:19 +02:00
Jonas Jenwald
00720d059a [api-minor] Include the /Lang-property in the documentInfo, and use it in the viewer (issue 14110)
*Please note:* This is a tentative patch, since I don't have the necessary a11y-software to actually test it.

To avoid having to add a new API-method just for a single string, I figured that adding the new property to the existing `documentInfo`-data (accessed via `PDFDocumentProxy.getMetadata` in the API) will hopefully be deemed acceptable.
2021-10-16 14:27:47 +02:00
Tim van der Meij
52fce0d17b
Merge pull request #14152 from Snuffleupagus/xfaFactory-typo
Fix a `xfaFaxtory` typo in the shadowing in the  `PDFDocument.xfaFactory` getter, and some other clean-up
2021-10-16 14:23:47 +02:00
Tim van der Meij
9890f35eec
Merge pull request #14103 from Snuffleupagus/PDFFindController-event
[api-minor] Change `PDFFindController` to use the "find"-event directly (issue 12731)
2021-10-16 14:03:36 +02:00
Jonas Jenwald
0041230072 Re-name the XFAFactory.numberPages getter to XFAFactory.numPages for consistency
All other similar getters are called `numPages` throughout the code-base, and improved consistency should always be a good thing.
2021-10-16 12:56:21 +02:00
Jonas Jenwald
0e5348180e Fix the inconsistent return type of the PDFDocument.isPureXfa getter
Also (slightly) simplifies a couple of small getters/methods related to the `XFAFactory`-instance.
2021-10-16 12:56:20 +02:00
Jonas Jenwald
cd94a44ca1 Remove some duplication in *simple* shadowed getters in src/core/-code
In these cases there's no good reason, in my opinion, to duplicate the `shadow`-lines since that unnecessarily increases the risk of simple typos (see the previous patch).
2021-10-16 12:56:17 +02:00
Jonas Jenwald
1450da4168 Fix a xfaFaxtory typo in the shadowing in the PDFDocument.xfaFactory getter
With this typo the shadowing doesn't actually work, which causes these checks to be unnecessarily repeated. In this particular case it didn't have a significant performance impact, however we should definately fix this nonetheless.
2021-10-16 11:54:12 +02:00
Jonas Jenwald
fa8c0ef616 [api-minor] Change PDFFindController to use the "find"-event directly (issue 12731)
Looking at the code, I do have to agree with the point made in issue 12731 about it being unexpected/unhelpful that the `PDFFindController.executeCommand`-method isn't directly usable with the "find"-event.
The reason for it being this way is, as so often, for historical reasons: The `executeCommand`-method was added (just) prior to the introduction of the `EventBus` in the viewer.

Obviously we cannot simply change the existing `PDFFindController.executeCommand`-method, since that'd be a breaking change in code which has existed for over five years.
Initially I figured that we could simply add a new method in `PDFFindController` that'd accept the state from the "find"-event, however after thinking about this and looking through the use-cases in the default viewer I settled on a slightly different approach: Let the `PDFFindController` just listen for the "find"-event (on the `EventBus`-instance) directly instead, which also removes one level of (unneeded) indirection during searching in the default viewer.

For GENERIC builds of the PDF.js library, the old `PDFFindController.executeCommand`-method is still available with a deprecation warning.
2021-10-16 10:36:22 +02:00
Jonas Jenwald
cd22c31752 Fix the remaining Promise.resolve(undefined) cases
Many years ago now there were some `Promise` implementations that had issues resolving with an *implicitly* `undefined` value. That should no longer be the case, and we've not been using the `Promise.resolve(undefined)` format for a long time, hence this patch fixes the few remaining cases.
2021-10-15 22:42:13 +02:00
Jonas Jenwald
a37bc609e8
Merge pull request #14149 from mikemando/path-1
Convert examples/learning/helloworld64.html to await/async
2021-10-15 22:35:31 +02:00
Tim van der Meij
e504e81cda
Merge pull request #14112 from Snuffleupagus/ScrollMode-PAGE
Add a new Page scrolling mode (issue 2638, 8952, 10907)
2021-10-15 21:40:51 +02:00
Tim van der Meij
ed3da19869
Merge pull request #14131 from Snuffleupagus/spreadMode-render-holes
Ensure that pre-rendering works correctly with spreadModes at higher zoom levels
2021-10-15 21:20:06 +02:00
Tim van der Meij
ef0713e055
Merge pull request #14148 from Snuffleupagus/editorconfig-json
Ensure that the EditorConfig rules apply to `*.json` and `*.pdf.link` files as well
2021-10-15 21:14:43 +02:00
michael-ikwuegbu
ec5e7445f6 Convert examples/learning/helloworld64.html to await/async 2021-10-15 20:00:54 +01:00
calixteman
6863f36880
Merge pull request #14145 from janekotovich/application/octet
XFA - Embedded image is missing
2021-10-15 06:24:52 -07:00
Jonas Jenwald
540d32c486 Ensure that the EditorConfig rules apply to *.json and *.pdf.link files as well
This looks like a simple oversight, given the other file formats listed, and should hopefully help new users when adding reference tests.
2021-10-15 13:46:11 +02:00
Jane-Kotovich
c2af309917 XFA - Embedded image is missing 2021-10-15 21:12:29 +10:00
Jonas Jenwald
fc56a781d3
Merge pull request #14141 from adenicole/master
Convert examples/text-only/pdf2svg.js to await/async
2021-10-15 11:35:05 +02:00
adenicole
fdf08ef3d2 converted examples/text-only/pdf2svg.js to await/async
Updated promise call back with await/async method
2021-10-15 09:54:10 +01:00
Jonas Jenwald
c1617be2d7
Merge pull request #14143 from raghav-wd/patch-1
docs: Fix grammatical error
2021-10-15 09:31:14 +02:00
Devansh Gupta
04aa710947
docs: Fix grammatical error 2021-10-15 01:09:09 +05:30
Jonas Jenwald
4b8496e70f
Merge pull request #14138 from catherinemds/await/async-issue
Convert examples/learning/helloworld.html to await/async
2021-10-14 21:02:47 +02:00
Catherine
47f60a7f22 Convert examples/learning/helloworld.html to await/async 2021-10-14 14:18:24 -04:00
Jonas Jenwald
9f9f07613f
Merge pull request #14134 from janekotovich/convert_pdf2png_to_async
Convert examples/node/pdf2png/pdf2png.js to await/async
2021-10-14 13:11:51 +02:00
Jane-Kotovich
37d90ec378 Convert examples/node/pdf2png/pdf2png.js to await/async 2021-10-14 20:35:18 +10:00
Jonas Jenwald
08e2427f9c Ensure that pre-rendering works correctly with spreadModes at higher zoom levels
Having recently worked with this code, in PR 14096 (and indirectly in PR 14112), I happened to notice a pre-existing issue with spreadModes at higher zoom levels.
The `PDFRenderingQueue` code was written back when the viewer only supported "normal" vertical scrolling, and some edge-cases related to spreadModes are thus not perfectly supported. Depending on the zoom level, it's possible that there are "holes" in the currently visible page layout, and those pages will not be pre-rendered as you'd expect.

*Steps to reproduce:*

 0. Open the viewer, e.g. https://mozilla.github.io/pdf.js/web/viewer.html
 1. Enable vertical scrolling.
 2. Enable the ODD spreadMode.
 3. Scroll down, such that both pages 1 and 3 are visible.
 4. Zoom-in until *only* page 1 and 3 are visible.
 5. Open the devtools and, using the DOM Inspector, notice how page 2 is *not* being pre-rendered despite all surrounding pages being rendered.
2021-10-14 11:20:49 +02:00
Tim van der Meij
f6d9d91965
Merge pull request #14116 from Snuffleupagus/api-more-optional-chaining
Use even more optional chaining in the `src/display/api.js` file
2021-10-13 19:38:03 +02:00
Jonas Jenwald
29fd87be57
Merge pull request #14118 from adventhp/cmap-format-2
Implement TrueType character map "format 2" (fixes #14117)
2021-10-13 15:15:46 +02:00
Jay Berkenbilt
586295fad6 Implement TrueType character map "format 2" (fixes #14117)
If a PDF included an embedded TrueType font whose preferred character
map (cmap) was in "format 2", the code would select that character map
and then refuse to read it because of an unsupported format, thus
causing the characters not to be rendered. This commit implements
support for format 2 as described at the link below.

https://developer.apple.com/fonts/TrueType-Reference-Manual/RM06/Chap6cmap.html
2021-10-13 07:37:14 -04:00
Jonas Jenwald
e1a2e916e8 Move PDFSinglePageViewer into the web/pdf_viewer.js file
With the previous commit, both of the `PDFViewer` and `PDFSinglePageViewer` clases are now small/simple enough that it no longer seems necessary to keep them in separate files.
2021-10-12 13:45:19 +02:00
Jonas Jenwald
511458fbbc Add a new Page scrolling mode (issue 2638, 8952, 10907)
This implements a new Page scrolling mode, essentially bringing (and extending) the functionality from `PDFSinglePageViewer` into the regular `PDFViewer`-class. Compared to `PDFSinglePageViewer`, which as its name suggests will only display one page at a time, in the `PDFViewer`-implementation this new Page scrolling mode also support spreadModes properly (somewhat similar to e.g. Adobe Reader).

Given the size and scope of these changes, I've tried to focus on implementing the basic functionality. Hence there's room for further clean-up and/or improvements, including e.g. simplifying the CSS/JS related to PresentationMode and implementing easier page-switching with the mouse-wheel/arrow-keys.
2021-10-12 13:45:15 +02:00
Jonas Jenwald
8fc9c7e41c Use even more optional chaining in the src/display/api.js file
This patch (slightly) simplifies a couple of `onProgress` and `onUnsupportedFeature` call-sites.
Finally, while unrelated, also removes some unnecessary `return undefined;` statements (PR 11601 follow-up).
2021-10-12 12:05:59 +02:00