Commit Graph

14875 Commits

Author SHA1 Message Date
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
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
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
Calixte Denizet
aecbd7cd89 AcroForm: Add support for ResetForm action
- it aims to fix #12721.
  - Thanks to PR #14023, we've now the fieldObjects in the annotation layer so we can easily map fields names on their id if needed.
  - Reset values in the storage, in the JS sandbox and in the visible html elements.
2021-09-30 22:02:33 +02:00
Jonas Jenwald
d3ca28bc34 Support CMap-data with only strings, when parsing TrueType composite fonts (bug 920426)
In the referenced bug, the embedded fonts contain custom CMap-data that only include strings. Note how for embedded composite TrueType fonts we're using the CMap-data when building the glyph mapping, and currently we end up with a completely empty map because the code expects only CID *numbers*.
Furthermore, just fixing the glyph mapping alone isn't sufficient to fully address the bug, since we also need to consider this "special" kind of CMap-data when looking up glyph widths.
2021-09-30 18:10:47 +02:00
calixteman
db7c91e7b1
Merge pull request #14091 from calixteman/14049_fu
Add the missing pdf file for the test in the PR #14049
2021-09-29 13:20:11 -07:00
Calixte Denizet
748ab4983c Add the missing pdf file for the test in the PR #14049 2021-09-29 22:07:07 +02:00
Tim van der Meij
9a74f3e6e0
Merge pull request #14049 from calixteman/bg_from_mk
Annotation - Use border and background colors from MK dictionary
2021-09-29 21:13:20 +02:00
Calixte Denizet
0776cd9b90 Annotation - Use border and background colors from MK dictionary
- it aims to fix #13003;
  - set the bg and fg colors as they're in the pdf;
  - put a transparent overlay to help to see the fields.
2021-09-26 20:49:26 +02:00
Tim van der Meij
93ed4bfa11
Merge pull request #14081 from Snuffleupagus/createValidAbsoluteUrl-options
[api-minor] Move the `addDefaultProtocolToUrl`/`tryConvertUrlEncoding` functionality into the `createValidAbsoluteUrl` function
2021-09-26 15:00:06 +02:00
Jonas Jenwald
e6e04694f4 [api-minor] Move the addDefaultProtocolToUrl/tryConvertUrlEncoding functionality into the createValidAbsoluteUrl function
Having recently worked with, and reviewed patches touching, this code it seemed that it's probably not a bad idea to move that functionality into `createValidAbsoluteUrl` as new options instead.

For the `addDefaultProtocolToUrl` functionality in particular, the existing helper function was not only moved but slightly improved as well. Looking at the code, I realized that there's a small risk that it would incorrectly match a *relative* URL-string too.

With these changes, the `createValidAbsoluteUrl` call-sites in the `src/core/`-code can be simplified a little bit.

*Please note:* This patch may, indirectly, change the format of the `unsafeUrl`-property returned with relevant Annotations and OutlineItems; hence the `api-minor` tag.
However, I'd argue that it's actually more correct this way since the whole purpose of `unsafeUrl` is/was to return the URL data as-is without any parsing done.
2021-09-26 14:29:54 +02:00
Jonas Jenwald
3b3c487bed
Merge pull request #14076 from calixteman/1716758
XFA - Add <a> element in button when an url is detected (bug 1716758)
2021-09-26 10:07:19 +02:00
Jonas Jenwald
f1ceb00ae4
Merge pull request #14077 from calixteman/driver
Fix issues in driver.js when getting css sheets
2021-09-25 23:32:11 +02:00
Calixte Denizet
558e58f354 XFA - Add <a> element in button when an url is detected (bug 1716758)
- it aims to fix https://bugzilla.mozilla.org/show_bug.cgi?id=1716758;
  - some buttons have a JS action with the pattern `app.launchURL(...)` (or similar) so extract when it's possible the url and generate a <a> element with the href equals to the found url;
  - pdf.js already had some code to handle that so this patch slightly refactor that.
2021-09-25 21:59:39 +02:00
calixteman
3b1d547738
Merge pull request #14036 from calixteman/14021
Annotation - Some checkboxes have an empty N dictionary
2021-09-25 10:34:03 -07:00
Calixte Denizet
4b96735e1d Fix issues in driver.js when getting css sheets 2021-09-25 17:56:30 +02:00
Calixte Denizet
c0e9108d00 Annotation - Some checkboxes have an empty N dictionary
- it aims to fix #14021;
  - the N dict is empty here so just create a default one;
  - it implies that the checked checkbox has no appearance so create a default one too in order to print it;
  - in the pdf in the issue, a checked box is not printed because it has no default appearance so we need to guess its appearance from its state.
2021-09-25 16:00:47 +02:00
Tim van der Meij
cc110b8542
Merge pull request #14064 from Snuffleupagus/issue-13845
Fallback to font name matching, when checking for serif fonts (issue 13845)
2021-09-25 12:41:57 +02:00