Commit Graph

14875 Commits

Author SHA1 Message Date
Tim van der Meij
168aa5efb1
Merge pull request #13988 from calixteman/issue13987
Avoid an error in integration test because of a locale different of en-US
2021-09-08 21:50:43 +02:00
Calixte Denizet
2b938c42f5 Avoid an error in integration test because of a locale different of en-US 2021-09-08 18:00:03 +02:00
Jonas Jenwald
69034ab8dc Improve glyph mapping for non-embedded composite standard fonts (issue 11088)
For non-embedded CIDFontType2 fonts with a non-/Identity encoding, use the /ToUnicode data to improve the glyph mapping.
2021-09-08 15:15:33 +02:00
Jonas Jenwald
b39cd706a6 Update the learning/ examples with basic HiDPI-screen support
This is essentially a simplified version of the code that's used in `PDFPageView`, which will hopefully reduce the number of issues opened specifically about blurry rendering.
However, note that *ideally* users should base their implementations on the `components/` examples rather than using the API directly (the "viewer components" already support HiDPI-screens).
2021-09-07 14:57:59 +02:00
Tim van der Meij
d95f680d66
Merge pull request #13976 from Snuffleupagus/_textDivProperties-cleanup
Reduce the size of `TextLayerRenderTask._textDivProperties` in "regular" text-selection mode
2021-09-05 14:45:17 +02:00
Tim van der Meij
e965aa39e6
Merge pull request #13975 from Snuffleupagus/update-packages
Update packages and translations
2021-09-05 13:36:05 +02:00
Jonas Jenwald
4c1b586dd2 Reduce the size of TextLayerRenderTask._textDivProperties in "regular" text-selection mode
While these changes will obviously not have a significant effect on overall memory usage, it cannot hurt as far as I'm concerned. This patch makes the following changes:
 - Clear out `_textDivProperties` once rendering is done, since those properties are only necessary to keep alive when *enhanced* text-selection is being used.

 - Reduce the size of the `_textDivProperties`-entries by default, since a majority of the properties are only relevant when *enhanced* text-selection is being used.
2021-09-05 12:12:34 +02:00
Jonas Jenwald
a6f8591cc2 Update l10n files 2021-09-05 10:01:23 +02:00
Jonas Jenwald
4bd1d51970 Update the webpack-stream package to the latest version 2021-09-05 09:58:59 +02:00
Jonas Jenwald
adb17bafa4 Update the needle package to the latest version 2021-09-05 09:56:50 +02:00
Jonas Jenwald
6adecdda80 Update the eslint-plugin-prettier package to the latest version
Please refer to https://github.com/prettier/eslint-plugin-prettier/blob/master/CHANGELOG.md#v400-2021-08-30
2021-09-05 09:54:18 +02:00
Jonas Jenwald
2643d29a03 Remove @babel/plugin-proposal-logical-assignment-operators from package.json (PR 13900 follow-up)
I missed this in PR 13900, sorry about that!
2021-09-05 09:50:57 +02:00
Jonas Jenwald
91bc559f3c Update npm packages 2021-09-05 09:47:57 +02:00
Tim van der Meij
1b20f61b56
Merge pull request #13972 from Snuffleupagus/issue-13971
Treat all content as visible when no optional content groups are defined (issue 13971)
2021-09-04 15:53:44 +02:00
Tim van der Meij
7889cfdc3c
Merge pull request #13973 from Snuffleupagus/viewer-components-refactor-update
[api-minor] Change `{PDFPageView, PDFThumbnailView}.update` to take a parameter object
2021-09-04 15:50:32 +02:00
Tim van der Meij
680f33c31c
Merge pull request #13961 from Snuffleupagus/simpler-regexp
Simplify some regular expressions
2021-09-04 15:39:30 +02:00
Jonas Jenwald
8466204384 [GENERIC viewer] Add fallback logic for the old PDFPageView.update method signature
This is done separately from the previous commit, to make it easier to revert these changes in the future.
2021-09-04 11:39:34 +02:00
Jonas Jenwald
7c81a8dd40 [api-minor] Change {PDFPageView, PDFThumbnailView}.update to take a parameter object
The old `update`-signature started to annoy me back when I added optional content support to the viewer, since we're (often) forced to pass in a bunch of arguments that we don't care about whenever these methods are called.

This is tagged `api-minor` since `PDFPageView` is being used in the `pageviewer` component example, and it's thus possible that these changes could affect some users; the next commit adds fallback handling for the old format.
2021-09-04 11:39:25 +02:00
Jonas Jenwald
258cf1decc
Merge pull request #13970 from Snuffleupagus/issue-13316
Fallback to the /ToUnicode map for TrueType fonts with (3, 1) and (1, 0) cmap-tables (issue 13316)
2021-09-04 09:34:39 +02:00
Jonas Jenwald
6318ccf6d2 Treat all content as visible when no optional content groups are defined (issue 13971)
In the referenced PDF document the /Contents stream contains MarkedContent-operators, however no optional content dictionary exists; according to [the specification](https://www.adobe.com/content/dam/acom/en/devnet/pdf/pdfs/PDF32000_2008.pdf#G7.3883825):

> Null values or references to deleted objects shall be ignored. If this entry is
  not present, is an empty array, or contains references only to null or deleted
  objects,  the  membership  dictionary  shall  have  no  effect  on  the  visibility  of
  any content.
2021-09-04 08:13:37 +02:00
Jonas Jenwald
3ccf277f58 Fallback to the /ToUnicode map for TrueType fonts with (3, 1) and (1, 0) cmap-tables (issue 13316)
In the PDF document some of the glyphs have bogus `differences`-entries[1] that cannot be resolved to valid glyph names, thus causing the glyph mapping to fail.
My initial idea was to use a similar approach as in the `PartialEvaluator._simpleFontToUnicode`-method, to extract the charCodes from those entries, however it turned out that that didn't actually help in this case (the mapping was still wrong).

To fix this I'm thus proposing that we fallback to the /ToUnicode map when no other useable data exists (e.g. no post-table), since it *hopefully* shouldn't make things any worse than leaving parts of the glyph map empty (which currently happens).

---
[1] As can be seem below, some of the entries are completely normal while others are non-standard:
```
Differences (array)
    0 = 65
    1 = /g5167
    2 = /space
    3 = /g11927
    4 = /g17737
    5 = /g11540
    6 = /g2180
    7 = /K
    8 = /P
    9 = /two
    10 = /zero
    11 = /one
    12 = /five
    13 = /four
    14 = /g6932
    15 = /g7246
    16 = /g1691
    17 = /g2343
    18 = /g14792
    19 = /g3325
    20 = /g4280
    21 = /g20383
    22 = /g18166
    23 = /g16988
    24 = /g17943
    25 = /g19223
    26 = /g10830
    27 = 97
    28 = /g982
    29 = /g1226
    30 = /g5059
    31 = /g2677
    32 = /g1042
    33 = /g11568
    34 = /L
    35 = /three
    36 = /seven
    37 = /g2364
    38 = /g12063
    39 = /g5356
    40 = /g2173
    41 = /g17877
    42 = /g7273
    43 = /g7647
    44 = /g7224
    45 = /g19327
    46 = /g5054
    47 = /g2342
    48 = /g10136
    49 = /g6856
    50 = /g13381
    51 = /g7257
    52 = /g12093
    53 = /g2359
```
2021-09-04 07:38:22 +02:00
Brendan Dahl
da15dbf962
Merge pull request #13698 from linfangrong/master
[FIX] fix jpx tag tree decode (issue 11957)
2021-09-03 10:00:19 -07:00
Brendan Dahl
a8ce15a2d7
Merge pull request #13966 from calixteman/no_ns
XFA - Created data node mustn't belong to datasets namespace
2021-09-03 09:59:40 -07:00
Brendan Dahl
d9d3115a7b
Merge pull request #13967 from calixteman/no_datasets
XFA - Overwrite AcroForm dictionary when saving if no datasets in XFA (bug 1720179)
2021-09-03 09:53:36 -07:00
Calixte Denizet
77b9657e57 XFA - Overwrite AcroForm dictionary when saving if no datasets in XFA (bug 1720179)
- aims to fix https://bugzilla.mozilla.org/show_bug.cgi?id=1720179
  - in some pdfs the XFA array in AcroForm dictionary doesn't contain an entry for 'datasets' (which contains saved data), so basically this patch allows to overwrite the AcroForm dictionary with an updated XFA array when doing an incremental update.
2021-09-03 17:04:03 +02:00
Calixte Denizet
57ae3a5a76 XFA - Created data node mustn't belong to datasets namespace
- when some named nodes in the template don't have their counterpart in datasets we create some nodes: the main node mustn't belong to the datasets namespace because it doesn't make sense and Acrobat Reader isn't able to read pdf with such nodes.
  - so created nodes under a datasets node have a namespaceId set to -1 and consequently when serialized no namespace prefix will appear.
2021-09-03 15:43:25 +02:00
Brendan Dahl
804abb3786
Merge pull request #13959 from calixteman/encrypt
Correctly pad strings when saving an encrypted pdf (bug 1726789)
2021-09-02 11:41:02 -07:00
Jonas Jenwald
c42887221a Simplify some regular expressions
There's a fair number of regular expressions througout the code-base which are slightly more verbose than strictly necessary, in particular:
 - We have a lot of regular expressions that use `[0-9]` explicitly, and those can be simplified to use `\d` instead.
 - We have one instance of a regular expression containing a `A-Za-z0-9_` sequence, which can be simplified to use `\w` instead.
2021-09-02 11:50:42 +02:00
Calixte Denizet
9619bf92be Correctly pad strings when saving an encrypted pdf (bug 1726789) 2021-09-02 10:37:21 +02:00
Tim van der Meij
0a366dda6a
Merge pull request #13955 from Snuffleupagus/issue-13433
Always prefer the post-table for TrueType fonts with (0, x) cmap-tables (issue 13433)
2021-09-01 21:46:34 +02:00
Tim van der Meij
19ce2de6f7
Merge pull request #13952 from Snuffleupagus/ItcSymbol
Extend `getNonStdFontMap` for non-embedded versions of the ItcSymbol font (issue 11532)
2021-09-01 21:38:59 +02:00
Tim van der Meij
2ed133bd99
Merge pull request #13945 from Snuffleupagus/network-onError
Implement `PDFNetworkStreamRangeRequestReader._onError`, to handle range request errors with XMLHttpRequest (issue 9883)
2021-09-01 21:18:07 +02:00
Jonas Jenwald
b7b6076294 Always prefer the post-table for TrueType fonts with (0, x) cmap-tables (issue 13433)
While I don't know if this is necessarily the "correct" solution, it does fix issue 13433 without breaking any of the existing reference-tests.
2021-09-01 12:35:49 +02:00
Jonas Jenwald
ba9f004097 Extend getNonStdFontMap for non-embedded versions of the ItcSymbol font (issue 11532)
Despite its name, the fonts in ItcSymbol-family are "regular" fonts and not Symbol ones. However, given that the font name contains the word "Symbol" we ended up picking the wrong code-path in the `Font.fallbackToSystemFont`-method.

*Please note:* While this patch ensures that the text becomes readable, by falling back a standard font, the rendering will obviously not be perfect. However, that's the PDF generators "fault" since non-embedded fonts cannot be guaranteed to render correctly in all environments.
2021-08-31 23:21:16 +02:00
Jonas Jenwald
07e233d08b
Merge pull request #13951 from mozilla/dependabot/npm_and_yarn/tar-4.4.19
Bump tar from 4.4.15 to 4.4.19
2021-08-31 20:20:46 +02:00
dependabot[bot]
e1c2151a03
Bump tar from 4.4.15 to 4.4.19
Bumps [tar](https://github.com/npm/node-tar) from 4.4.15 to 4.4.19.
- [Release notes](https://github.com/npm/node-tar/releases)
- [Changelog](https://github.com/npm/node-tar/blob/main/CHANGELOG.md)
- [Commits](https://github.com/npm/node-tar/compare/v4.4.15...v4.4.19)

---
updated-dependencies:
- dependency-name: tar
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
2021-08-31 16:39:41 +00:00
Jonas Jenwald
1f56451d56 Implement PDFNetworkStreamRangeRequestReader._onError, to handle range request errors with XMLHttpRequest (issue 9883)
Given that the Fetch API is normally being used now, these changes are probably less important now than they used to be. However, given that it's simple enough to implement this I figured why not just fix issue 9883 (better late than never I suppose).
2021-08-31 10:23:57 +02:00
Jonas Jenwald
bd9a92a161 Use optional chaining more in the src/display/network.js file
Also changes the different `_onDone`/`_onProgress` methods to use consistent parameter names, and some other small improvements.
2021-08-31 10:23:54 +02:00
linfangrong
369f1899c6 [FIX] fix jpx tag tree decode (issue 11957) 2021-08-31 11:44:26 +08:00
Jonas Jenwald
72c34b2964
Merge pull request #13949 from brendandahl/bug1727053
Only use base encoding if it's populated. (bug 1727053)
2021-08-30 23:43:01 +02:00
Brendan Dahl
a7f807b059 Only use base encoding if it's populated. (bug 1727053)
The font dict in this file has an encoding entry, but only specifies a
differences map. The base encoding is empty in this case and shouldn't
be used.
2021-08-30 12:51:59 -07:00
Brendan Dahl
306119b12a
Merge pull request #13932 from Snuffleupagus/oc-images
Support Optional Content in Image-/XObjects (issue 13931)
2021-08-30 10:10:14 -07:00
Jonas Jenwald
cf0ccc4bab
Merge pull request #13937 from overleaf/jpa-fix-error-handling
Fix handling of fetch errors
2021-08-30 15:50:03 +02:00
Jakob Ackermann
291ffd3059
Fix handling of fetch errors
Testing:
- delete the pdf file while the initial request is inflight
- delete the pdf file after the initial request has finished

Repeat for a small file and large file, exercising both one-off and
 chunked transports.
2021-08-30 12:43:28 +01:00
Tim van der Meij
e18d577ace
Merge pull request #13944 from Snuffleupagus/setPDFNetworkStreamFactory-unit
Re-factor the `setPDFNetworkStreamFactory` usage for the unit-tests (PR 13549 follow-up)
2021-08-29 18:51:21 +02:00
Jonas Jenwald
e69afc6f3d Re-factor the setPDFNetworkStreamFactory usage for the unit-tests (PR 13549 follow-up)
This should have been part of PR 13549, since we no longer support browsers without native Fetch API and ReadableStream implementations.
2021-08-29 18:27:53 +02:00
Tim van der Meij
954e1a1694
Merge pull request #13943 from Snuffleupagus/api-more-async
Use `async` a bit more in the API
2021-08-29 14:34:14 +02:00
Tim van der Meij
a270baeb67
Merge pull request #13942 from Snuffleupagus/viewer-components-export-layers
Export the XFA/StructTree-layers in the viewer components
2021-08-29 14:30:28 +02:00
Tim van der Meij
13bc661681
Merge pull request #13941 from Snuffleupagus/MessageHandler-PasswordException
Ensure that `PasswordException` is handled correctly in the `wrapReason` function
2021-08-29 14:23:46 +02:00
Jonas Jenwald
ce3f5ea2bf Use async a bit more in the API
This patch changes the `PDFDocumentLoadingTask.destroy`-method and the `_fetchDocument`-function to be `async`, which slightly simplifies the relevant code.

Furthermore, remove the catch-handler from the `WorkerTransport.getPageIndex`-method since it's no longer needed. Given that the `MessageHandler` is nowadays wrapping every possible Exception, it's no longer necessary to try and re-wrap the reason here.
2021-08-29 12:31:28 +02:00