Commit Graph

14793 Commits

Author SHA1 Message Date
Tim van der Meij
580bfad628
Merge pull request #14053 from Snuffleupagus/BaseViewer-zoom-in/out
Move the zoomIn/zoomOut functionality into `BaseViewer` (PR 14038 follow-up)
2021-09-19 13:19:42 +02:00
Tim van der Meij
c7dd99da76
Merge pull request #14050 from Snuffleupagus/issue-14048
Tweak how fonts with an /Encoding are handled in `adjustToUnicode` (issue 14048, PR 13277 follow-up)
2021-09-19 12:42:43 +02:00
Tim van der Meij
92be4645a9
Merge pull request #14052 from Snuffleupagus/update-packages
Update packages and translations
2021-09-19 12:30:42 +02:00
Jonas Jenwald
d9f9fa4f1c Move the zoomIn/zoomOut functionality into BaseViewer (PR 14038 follow-up)
Given the simplicity of this functionality, we can move it from the default viewer and into the `BaseViewer` class instead. This way, it's possible to support more scripting functionality in the standalone viewer components; please see PR 14038.

Please note that I purposely went with `increaseScale`/`decreaseScale`-method names, rather than using "zoom", to better match the existing `currentScale`/`currentScaleValue` getters/setters that's being used in the `BaseViewer` class.
2021-09-19 11:54:57 +02:00
Jonas Jenwald
32ad677f9c Update l10n files 2021-09-19 09:43:15 +02:00
Jonas Jenwald
a09d7797fb Update the eslint-plugin-unicorn package to the latest version
Please refer to https://github.com/sindresorhus/eslint-plugin-unicorn/releases/tag/v36.0.0
2021-09-19 09:39:56 +02:00
Jonas Jenwald
57734b11f6 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-09-19 09:33:05 +02:00
Jonas Jenwald
8679bb7aab Update npm packages 2021-09-19 09:31:42 +02:00
Jonas Jenwald
8ea27ce157 Tweak how fonts with an /Encoding are handled in adjustToUnicode (issue 14048, PR 13277 follow-up)
Currently we only exclude /Encoding entries that also contains a /Differences array, which is the cause of the text-selection problem in the referenced issue.
In order to address this we'll now also exclude /Encoding entries that contain one of the predefined *named* encodings, and no longer require that it also contains a /Differences array.

*Please note:* This patch cases a small "regression" in the `bug1130815-text` test-case, however this is actually an improvement when compared with Adobe Reader and PDFium (in Google Chrome).
2021-09-18 22:44:25 +02:00
Tim van der Meij
83d3bb43f4
Merge pull request #14041 from Snuffleupagus/issue-9367
Support cmaps with only CID characters, when building the ToUnicode-map (issue 9367)
2021-09-18 16:47:06 +02:00
Jonas Jenwald
20eb6ca2ec
Merge pull request #14044 from calixteman/bug1719148
Annotations - Avoid empty value in text field when storage contains something for it (bug 1719148)
2021-09-18 16:31:45 +02:00
Tim van der Meij
2375318a70
Merge pull request #14005 from Snuffleupagus/issue-13997
[GENERIC viewer] Always show the Download-buttons, to allow saving of forms (issue 13997)
2021-09-18 16:31:15 +02:00
Jonas Jenwald
6634afd646
Merge pull request #14045 from calixteman/noise
XFA - Only warn about the wrong xfa type when there is an xfa thing
2021-09-18 16:13:20 +02:00
Tim van der Meij
c870fb489e
Merge pull request #14013 from Snuffleupagus/api-unittest-instanceof
Improve the API unit-tests, and try to expose more API-functionality in the TypeScript definitions
2021-09-18 16:08:19 +02:00
Tim van der Meij
213f3d4cbf
Merge pull request #14043 from Snuffleupagus/AutomationEventBus
Re-factor the `EventBus` and `isInAutomation` handling (PR 11655 follow-up)
2021-09-18 16:02:55 +02:00
Calixte Denizet
2fc10727c5 XFA - Only warn about the wrong xfa type when there is an xfa thing 2021-09-18 15:44:05 +02:00
calixteman
ffa2572bdf
Merge pull request #14038 from calixteman/saveas
JS - Implement few possibilities with app.execMenuItem (bug 1724399)
2021-09-18 15:33:03 +02:00
calixteman
f30e862a72
Merge pull request #14040 from calixteman/14039
JS - Avoid the Stay/Leave popup when clicking on a button with a JS action
2021-09-18 15:31:49 +02:00
Calixte Denizet
eb762ad624 Annotations - Avoid empty value in text field when storage contains something for it (bug 1719148)
- it aims to fix https://bugzilla.mozilla.org/show_bug.cgi?id=1719148;
  - JS can set a property for a non-rendered annotation using the annotationStorage but the other unset default properties must be used when the annotation is finally rendered;
  - so this patch just adds the properties already set in the annotationStorage to the default value.
2021-09-18 15:08:22 +02:00
Calixte Denizet
bfd570038d JS - Implement few possibilities with app.execMenuItem (bug 1724399)
- it aims to fix: https://bugzilla.mozilla.org/show_bug.cgi?id=1724399.
2021-09-18 13:52:32 +02:00
Jonas Jenwald
e3223b68fc Extract some of the glyphMap handling, for non-embedded composite standard fonts, into a helper function
This reduces some unnecessary duplication, since we currently have essentially the same code in a handful of places in the `Font.fallbackToSystemFont`-method.
2021-09-18 12:39:48 +02:00
Jonas Jenwald
0e92f995c9 Re-factor the EventBus and isInAutomation handling (PR 11655 follow-up)
Rather than forcing the "regular" `EventBus` to check and handle `isInAutomation` for every `dispatch` call, we can take advantage of subclassing instead.
Hence this PR introduces a new `AutomationEventBus` class, which extends `EventBus`, and is used by the default viewer when `isInAutomation === true`.
2021-09-18 09:59:53 +02:00
Jonas Jenwald
ed73cf6d50 Support cmaps with only CID characters, when building the ToUnicode-map (issue 9367)
In this particular case the `CMap`-data that we create contains only numbers, but no strings, which causes `PartialEvaluator.readToUnicode` to create a ToUnicode-map with only empty strings.

*Please note:* This is yet another case where I don't know if it's necessarily the best and most correct solution, but it does fix the referenced issue.
2021-09-18 00:26:15 +02:00
Calixte Denizet
e87c12bf34 JS - Avoid the Stay/Leave popup when clicking on a button with a JS action
- it aims to fix #14039.
2021-09-17 21:04:07 +02:00
calixteman
7082ff9bf8
Merge pull request #14035 from calixteman/1722036
Annotation - For checkboxes, get field value from AS (if any) instead of V (bug 1722036)
2021-09-17 14:59:49 +02:00
Calixte Denizet
5bef8120e7 Annotation - For checkboxes, get field value from AS (if any) instead of V (bug 1722036)
- it aims to fix https://bugzilla.mozilla.org/show_bug.cgi?id=1722036.
  - AS and V should share the same value for checkbox: it's at least what the specs say;
  - the pdf in the above bug opens correctly in Acrobat so it likely means that AS is chosen over V.
2021-09-17 13:04:16 +02:00
Brendan Dahl
d6a27860e3
Merge pull request #14025 from Snuffleupagus/issue-11915
Improve glyph mapping for non-embedded composite standard fonts with a /CIDToGIDMap (issue 11915)
2021-09-16 08:06:35 -07:00
Jonas Jenwald
9745b75858 [GENERIC viewer] Always show the Download-buttons, to allow saving of forms (issue 13997)
Originally the library/viewer didn't support forms, and the hiding of the Download-buttons (when new documents are opened) didn't really matter all that much. Hence the simplest solution, at the time, was to hide the Download-buttons since we use the URL as a fallback when downloading data in the GENERIC `DownloadManager`.
Nowadays we obviously want to support saving of forms in the GENERIC viewer, regardless of how the document was opened, which could thus *potentially* lead to the fallback download-URL being wrong.

In order to be able to show the Download-buttons unconditionally, this patch slightly re-factors the viewer to track the download-URL *separately* to prevent any issues there.

*Please note:* As mentioned in the issue, the ViewBookmark-buttons are specific to the initial URL when the viewer is first opened. Hence they (still) don't make sense when a new document has been opened, since it's then impossible to obtain a usable link to the *currently* active document.
2021-09-15 23:51:56 +02:00
Tim van der Meij
95435ed66f
Merge pull request #13984 from Snuffleupagus/viewer-enableXfa
Enable XFA by default in the viewer, and `components/` examples (issue 13968)
2021-09-15 22:44:59 +02:00
Tim van der Meij
1e2cb72ad4
Merge pull request #14028 from Snuffleupagus/_adjustScaleWidth-CSS-variables
Use CSS variables for setting the width of the zoom dropdown (PR 11570 follow-up)
2021-09-15 22:40:47 +02:00
Jonas Jenwald
4a7976f097 Use CSS variables for setting the width of the zoom dropdown (PR 11570 follow-up)
By using CSS variables to set the width of the zoom dropdown, we can simplify both the relevant CSS and JS code. This will not only improve overall maintainability of this code, but should also make it (slightly) easier for third-party users that want to customize the width.

Note in particular that by having the code in `Toolbar._adjustScaleWidth` lookup the values of the CSS variables, we no longer need to worry about keeping hard-coded values up-to-date with the CSS rules.
2021-09-15 15:51:30 +02:00
calixteman
8c2ac85b0a
Merge pull request #14027 from calixteman/14024
Annotation - Checkboxes with the same name and export values must be in unison
2021-09-15 15:42:26 +02:00
Calixte Denizet
a3aa6dd6ab Annotation - Checkboxes with the same name and export values must be in unison
- it aims to fix #14024.
  - this patch adds an attribute `acroformExportValue` to the HTML input in order to set the checked attribute in taking into account the exportValue for the checkboxes with the same name.
2021-09-15 15:30:24 +02:00
Jonas Jenwald
a11343e9af Improve glyph mapping for non-embedded composite standard fonts with a /CIDToGIDMap (issue 11915)
*Please note:* All of this feels very handwavy, but at least it passes all tests locally. Hopefully we have enough tests for this part of the font code.

For non-embedded composite standard fonts with an "incomplete" /CIDToGIDMap, we'll now fallback to an *explicitly defined* /ToUnicode map even when that one happens to be an /Identity-H or /Identity-V map.

The `Font.fallbackToSystemFont` method is unfortunately getting more and more special-cases, however that might be unavoidable given all the weird non-embedded fonts found in the wild :-(
2021-09-15 11:30:40 +02:00
Brendan Dahl
7fb653b19a
Merge pull request #14018 from calixteman/mime
XFA - Don't create images for unsupported mime types
2021-09-14 09:38:53 -07:00
Jonas Jenwald
7498b97aaa Enable XFA by default in the viewer, and components/ examples (issue 13968)
Given that https://bugzilla.mozilla.org/show_bug.cgi?id=1727396 has now landed, it should now be OK to make this change.
2021-09-14 16:54:36 +02:00
Calixte Denizet
9812e35916 XFA - Don't create images for unsupported mime types 2021-09-14 10:55:25 +02:00
Jonas Jenwald
95057a4e56 Try to expose more API-functionality in the TypeScript definitions
While these types apparently makes sense in TypeScript environments, we really don't want to extend the *public* API by simply exporting the relevant classes directly in `src/pdf.js` (since they should never be called/initialized manually).

Please see e.g. issue 12384 where this was first requested, and note that a possible work-around was also provided there. This patch simply implements that work-around[1], which will hopefully be helpful to TypeScript users.

---
[1] Based on the discussion in PR 13957, the two previous patches appear to be necessary for this to actually work.
2021-09-13 13:57:56 +02:00
Jonas Jenwald
d854352cd5 Improve the API unit-tests by checking that PDFPageProxy.render returns a RenderTask-instance
This is similar to existing unit-tests, which checks for `PDFDocumentProxy`- and `PDFPageProxy`-instances.
2021-09-13 13:34:37 +02:00
Jonas Jenwald
fa7a607d33 Improve the API unit-tests by checking that getDocument returns a PDFDocumentLoadingTask-instance
This is similar to existing unit-tests, which checks for `PDFDocumentProxy`- and `PDFPageProxy`-instances.
2021-09-13 13:34:28 +02:00
Jonas Jenwald
064c21d360
Merge pull request #14007 from Snuffleupagus/writeValue-null
[src/core/writer.js] Support `null` values in the `writeValue` function
2021-09-12 19:05:36 +02:00
Jonas Jenwald
7025b9f859 [src/core/writer.js] Support null values in the writeValue function
*This fixes something that I noticed, having recently looked at both the `Lexer.getObj` and `writeValue` code.*

Please note that I unfortunately don't have an example of a form where saving fails without this patch. However, given its overall simplicity and that unit-tests are added, it's hopefully deemed useful to fix this potential issue pro-actively rather than waiting for a bug report.

At this point one might, and rightly so, wonder if there's actually any real-world PDF documents where a `null` value is being used?
Unfortunately the answer is *yes*, and we have a couple of examples in the test-suite (although none of those are related to forms); please see: `issue1015`, `issue2642`, `issue10402`, `issue12823`, `issue13823`, and `pr12564`.
2021-09-12 18:24:37 +02:00
Jonas Jenwald
8f72fc561e
Merge pull request #14006 from Snuffleupagus/writeValue-boolean
[src/core/writer.js] Remove unnecessary string-wrapping for boolean values in `writeValue` (PR 13998 follow-up)
2021-09-12 17:05:33 +02:00
Jonas Jenwald
5d578ea36a [src/core/writer.js] Remove unnecessary string-wrapping for boolean values in writeValue (PR 13998 follow-up) 2021-09-12 15:45:45 +02:00
Jonas Jenwald
761519ef3f
Merge pull request #13998 from calixteman/bug1729971
Write boolean value when saving a form (bug 1729971)
2021-09-12 15:38:10 +02:00
Tim van der Meij
0be35020da
Merge pull request #14002 from Snuffleupagus/issue-13999
Let `Lexer.getObj` return a dummy-`Cmd` for commands that start with a non-visible ASCII character (issue 13999)
2021-09-12 13:41:29 +02:00
Jonas Jenwald
6a24002ccc
Merge pull request #14004 from Rob--W/crx-disable-js-by-default
[CRX] enableScripting=false by default in Chrome extension
2021-09-12 01:36:01 +02:00
Rob Wu
628e672765 [CRX] enableScripting=false by default in Chrome extension
The scripting engine is bundled for users who'd like to use the feature,
but it is disabled by default.
2021-09-12 01:13:27 +02:00
Jonas Jenwald
a47844d1fc Let Lexer.getObj return a dummy-Cmd for commands that start with a non-visible ASCII character (issue 13999)
This way we avoid breaking badly generated PDF documents where a non-visible ASCII character is "glued" to a valid command.
2021-09-11 19:54:13 +02:00
Tim van der Meij
99e442941c
Merge pull request #13983 from Snuffleupagus/examples-learning-HiDPI
Update the `learning/` examples with basic HiDPI-screen support
2021-09-11 13:37:02 +02:00