Commit Graph

14890 Commits

Author SHA1 Message Date
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
Tim van der Meij
3945965605
Merge pull request #14108 from Snuffleupagus/issue-14107
For Annotations that define a closed area, make all of it toggle the PopupAnnotation (issue 14107)
2021-10-10 15:29:54 +02:00
Jonas Jenwald
8721557a08 For Annotations that define a closed area, make all of it toggle the PopupAnnotation (issue 14107)
For Circle, Square, and Polygon Annotations it's currently only possible to toggle the associated PopupAnnotation by clicking on its border. Depending on the border width, and also the current zoom-level in the viewer, that can make interacting with certain Annotations *practically* impossible (which is the case in issue 14107).
Hence, in order to improve this, change the "fill"-property of the SVG element in the annotationLayer to make the *entire* element part of the click/mouse-over target.

*Please note:* Given that this is a viewer-related issue, there's no simple way to test this as far as I can tell.
2021-10-09 15:55:15 +02:00
Tim van der Meij
56e3ef68d4
Merge pull request #14106 from calixteman/names
Empty name is allowed in ISO 32000
2021-10-09 14:29:10 +02:00
Tim van der Meij
63370ff12f
Merge pull request #14111 from Snuffleupagus/bug-1734802
Take the /CIDToGIDMap data into account when computing the hash, in `PartialEvaluator.preEvaluateFont`, for composite fonts (bug 1734802)
2021-10-09 14:25:25 +02:00
Jonas Jenwald
69a97bcba7 Take the /CIDToGIDMap data into account when computing the hash, in PartialEvaluator.preEvaluateFont, for composite fonts (bug 1734802)
This is unfortunately *yet another* bug in the `preEvaluateFont`-implementation, and I've lost count of the number of times I've had to tweak this code over the years :-(
I really cannot help thinking that PR 4423 was way too simplistic, since it missed a bunch of cases that leads to broken font rendering in many PDF documents.

Fixes https://bugzilla.mozilla.org/show_bug.cgi?id=1734802
2021-10-08 13:15:21 +02:00
Calixte Denizet
f384ad2356 Empty name is allowed in ISO 32000
- the exact sentence from the spec:
    "The token SOLIDUS (a slash followed by no regular characters) introduces a unique valid name defined by the empty sequence of characters."
  - so just remove the warning.
2021-10-06 20:50:39 +02:00
Jonas Jenwald
da8df646f5
Merge pull request #14101 from Snuffleupagus/comb-regression
[Regression] Fix comb fields scrolling when the last character is entered (PR 14049 follow-up)
2021-10-06 09:44:28 +02:00
Jonas Jenwald
8010181078 [Regression] Fix comb fields scrolling when the last character is entered (PR 14049 follow-up)
Note that PR 14049 removed this, since https://github.com/mozilla/pdf.js/pull/14049#discussion_r716245518 claimed that it's not necessary anymore. Unfortunately that, in my testing on Windows, actually re-introduced exactly the issue described in the comment; more specifically once the *last* character has been entered in the comb-field it's now again incorrectly scrolled (with the first character being invisible) until focus is lost.

This can be tested with e.g. `f1040.pdf`, see page 2, from the test-suite.
2021-10-05 09:36:08 +02:00
Tim van der Meij
f5b79be0b7
Merge pull request #13948 from Snuffleupagus/structuredClone
Use the native `structuredClone` implementation when it's available
2021-10-03 13:19:36 +02:00
Tim van der Meij
b9a2c4a817
Merge pull request #14099 from Snuffleupagus/update-packages
Update packages and translations
2021-10-03 13:14:53 +02:00
Jonas Jenwald
d49b1bf2ee Use the native structuredClone implementation when it's available
With a recent addition to the HTML specification, the internal structured clone algorithm used in browsers is (or will be, once it's implemented) *directly* accessible to JavaScript; please see https://developer.mozilla.org/en-US/docs/Web/API/WindowOrWorkerGlobalScope/structuredClone

Hence we'll *eventually* not need to maintain our own structured clone functionality in the `LoopbackPort`-class in the API, however for the time being we'll feature detect `structuredClone` and fallback to the existing PDF.js implementation.

Given that https://bugzilla.mozilla.org/show_bug.cgi?id=1722576 has landed in Firefox 94, we should no longer need the manually implemented `cloneValue`-functionality in MOZCENTRAL builds. Note also that in the Firefox built-in PDF Viewer it's not possible for users to *easily* disable workers, which should further reduce the risk of these changes.
2021-10-03 10:55:33 +02:00
Jonas Jenwald
65118bc04d Update l10n files 2021-10-03 08:33:21 +02:00
Jonas Jenwald
de18c35c9b Update the es-module-shims package to the latest version
Please refer to https://github.com/guybedford/es-module-shims/blob/main/CHANGELOG.md
2021-10-03 08:30:20 +02:00
Jonas Jenwald
ff271f2cff Update npm packages 2021-10-03 08:30:18 +02:00
Tim van der Meij
a474d6c30f
Merge pull request #14097 from timvandermeij/bump
Bump versions in `pdfjs.config`
2021-10-02 15:00:59 +02:00
Tim van der Meij
9e3e609b8e
Bump versions in pdfjs.config 2021-10-02 14:56:14 +02:00
Tim van der Meij
dedff3c982
Merge pull request #14096 from Snuffleupagus/spreadMode-preRender
Pre-render *one* additional page when spreadModes are enabled
2021-10-02 12:54:19 +02:00
Tim van der Meij
7beb67af7b
Merge pull request #14092 from Snuffleupagus/xfa-addLinkAttributes
[api-minor] Ensure that various URL-related options are applied in the `xfaLayer` too
2021-10-02 12:39:10 +02:00
Jonas Jenwald
8cb6efec2d [api-minor] Add a wrapper around the addLinkAttributes-function, in the API, to the PDFLinkService implementations
This patch helps reduce some duplication, given that we now have a few essentially identical `addLinkAttributes` call-sites in the code-base.
To prevent runtime errors in the Annotation/XFA-layer code, we'll warn if a custom/incomplete `PDFLinkService` is being used (limited to GENERIC builds).
2021-10-02 12:28:00 +02:00
Jonas Jenwald
e4794a678a Pre-render *one* additional page when spreadModes are enabled
Please note that we (obviously) don't want to unconditionally pre-render more than one page all the time, since that could very easily lead to overall worse performance in some documents.[1]
However, when spreadModes are enabled it does make sense to attempt to pre-render both of the pages of the next/previous spread.

---
[1] Since it may cause pre-rendering to unnecessarily compete for parsing resources, on the worker-thread, with "regular" rendering.
2021-10-02 11:57:34 +02:00
Jonas Jenwald
fb6c807ba2 Reduce unnecessary duplication in PDFRenderingQueue.getHighestPriority 2021-10-02 11:57:32 +02:00
Jonas Jenwald
bb9c905c5d Ensure that various URL-related options are applied in the xfaLayer too
Note how both the annotationLayer and the document outline will apply various URL-related options when creating the link-elements.
For consistency the `xfaLayer`-rendering should obviously use the same options, to ensure that the existing options are indeed applied to all URLs regardless of where they originate.
2021-10-02 09:32:23 +02:00
Jonas Jenwald
284d259054
Merge pull request #14057 from Snuffleupagus/bug-920426
Support CMap-data with only strings, when parsing TrueType composite fonts (bug 920426)
2021-10-01 23:22:25 +02:00
Jonas Jenwald
d588f5f961
Merge pull request #14095 from Snuffleupagus/annotationLayer-rm-forEach
Replace a couple of `Array.prototype.forEach`-invocations with `for..of` instead
2021-10-01 09:55:14 +02:00
Jonas Jenwald
67a642c826 Replace a couple of Array.prototype.forEach-invocations with for..of instead
Given that `NodeList`s can be iterated using `for..of` we can use that instead, since it's a little bit nicer and easier to read than the `Array.prototype.forEach` format.
2021-10-01 09:06:17 +02:00
calixteman
09361a4bb4
Merge pull request #14083 from calixteman/reset
AcroForm: Add support for ResetForm action
2021-09-30 13:22:09 -07:00