Commit Graph

14128 Commits

Author SHA1 Message Date
Tim van der Meij
d725ff36f1
Merge pull request #13460 from nikolas/patch-1
Update webpack import instructions
2021-05-29 15:43:34 +02:00
nikolas
4902f9a54a
Update webpack import instructions
This resolves an issue I had when loading pdf.js with webpack. `pdfjsLib` was always `undefined` after the import, and I dug deep into pdf.js's `webpack.js` file to sort out this issue, making all sorts of changes.

I figured out that there was just something wrong with the export/import procedure. After making this change, I now have the full pdfjs object in my webpack application.
2021-05-28 20:46:56 -04:00
Tim van der Meij
a0ce3cb3b4
Merge pull request #13448 from Snuffleupagus/_setDefaultAppearance-alpha
Support strokeAlpha/fillAlpha when creating a fallback appearance stream (issue 6810)
2021-05-28 23:39:36 +02:00
Tim van der Meij
5e5641b147
Merge pull request #13457 from Snuffleupagus/issue-13242
Work-around for HighlightAnnotations without a top-level /ExtGState-entry (issue 13242)
2021-05-28 23:38:39 +02:00
Tim van der Meij
0d56b1c365
Merge pull request #13443 from Snuffleupagus/charsCache
Re-factor the `charsCache` on `Font`-instances
2021-05-28 21:29:57 +02:00
Brendan Dahl
a6484c9861
Merge pull request #13427 from calixteman/xfa_storage
XFA - Add a storage to save fields values
2021-05-28 12:10:08 -07:00
Jonas Jenwald
707a9e3b02 Work-around for HighlightAnnotations without a top-level /ExtGState-entry (issue 13242)
For HighlightAnnotations with a built-in appearance stream, we still rely on it to specify the opacity correctly via a suitable blend mode. However, if the Annotation-drawing operators are placed *within* a /XObject of the /Form-type, the /ExtGState won't apply to the final rendering and the result is that the highlighting obscures the underlying text.

The more *correct* and general solution would likely be to somehow modify the implementation in `src/display/canvas.js`, to special-case handling of /Form-type /XObjects when rendering Annotations. Since we can very easily work-around this problem for now by using the "no appearance stream" code-path, doing *something* here ought to be preferable.

This patch is (obviously) merely a work-around, but given that the referenced issue is (as far as I know) the first case we've seen of this problem a simple solution will hopefully suffice for now.
2021-05-28 13:49:27 +02:00
calixteman
e499521b78
Merge pull request #13456 from calixteman/clazz
Replace clazz by classNames
2021-05-28 12:18:27 +02:00
Jonas Jenwald
2cc3b96351
Merge pull request #13455 from calixteman/italic
Italic angle is defined clockwise in CSS when it's counterclockwise in PDF
2021-05-28 11:49:48 +02:00
Calixte Denizet
f35176a32e Replace clazz by classNames 2021-05-28 11:17:38 +02:00
Calixte Denizet
1b0006093d Italic angle is defined clockwise in CSS when it's counterclockwise in PDF 2021-05-28 11:06:11 +02:00
calixteman
d285580f48
Merge pull request #13450 from Snuffleupagus/getPageIndex-JSDoc
Fix the JSDocs for `PDFDocumentProxy.getPageIndex` (issue 13449)
2021-05-27 17:25:41 +02:00
Jonas Jenwald
70c79c6f69 Fix the JSDocs for PDFDocumentProxy.getPageIndex (issue 13449) 2021-05-27 16:41:08 +02:00
Jonas Jenwald
52c13326cd Support Annotations, without appearance streams, with bogus /Rect-entries (issue 13447)
This extends PR 13106 to apply not only to empty /Rect-entries, but also to bogus /Rect-entries for various Annotation-types.
2021-05-27 16:23:21 +02:00
Jonas Jenwald
a6447f2ca2 Support strokeAlpha/fillAlpha when creating a fallback appearance stream (issue 6810)
This fixes the colours, by respecting the strokeAlpha/fillAlpha-values, for a couple of Annotations in the PDF document from issue 13447.[1]

---
[1] Some of the annotations still won't render at all, when compared with Adobe Reader, but that could/should probably be handled separately.
2021-05-27 16:23:18 +02:00
calixteman
f587d5998e
Merge pull request #13445 from calixteman/ps_name
Fix Postscript name in font to avoid bug when saving in pdf
2021-05-27 13:52:47 +02:00
Calixte Denizet
0c698346b8 Fix Postscript name in font to avoid bug when saving in pdf
- for xfa rendering, fonts are loaded and used in html;
  - when printed and saved in pdf, on linux, Firefox uses cairo backend
  - when subsetting a font, cairo uses the font postscript name and when this one is empty that leads to a bug
    (the append at 63f0d62684/src/cairo-cff-subset.c (L2049) is failing because of null length)
  - so this patch adds a postscript name to the font to make cairo happy.
2021-05-27 12:45:40 +02:00
Jonas Jenwald
8b1d01816b Re-factor the charsCache on Font-instances
Currently `charsCache` is initialized *lazily*, which considering that it just contains a simple `Object` doesn't seem entirely necessary. This first of all forces us to do repeated exists-checks in the `Font.charsToGlyphs` method, and secondly the similar/related `glyphCache` is already initialized eagerly.

Furthermore, this patch also does a bit of clean-up in the `Font.charsToGlyphs` method since this code is quite old.
2021-05-26 13:13:44 +02:00
Tim van der Meij
3da9f077be
Merge pull request #13435 from Snuffleupagus/eslint-no-array-push-push
Enable the `unicorn/no-array-push-push` ESLint plugin rule
2021-05-25 21:10:01 +02:00
Tim van der Meij
6e92b56efa
Merge pull request #13436 from Snuffleupagus/getPathGenerator-buf
Re-factor FontFaceObject.getPathGenerator to use Arrays instead of strings
2021-05-25 20:35:01 +02:00
Tim van der Meij
774f4da9cb
Merge pull request #13429 from mozilla/dependabot/npm_and_yarn/browserslist-4.16.6
Bump browserslist from 4.16.3 to 4.16.6
2021-05-25 20:29:46 +02:00
Calixte Denizet
9478d2f064 XFA - Add a storage to save fields values - this is required to be able to print (or save) a document. Some pages can be unloaded (because pdf.js is lazy) and this storage will help to save their data in order to resuse them when printing or just when displaying a page again. 2021-05-25 19:25:09 +02:00
calixteman
4d26623e59
Merge pull request #13402 from calixteman/xfa_layout1
XFA - Fix lot of layout issues
2021-05-25 18:31:53 +02:00
Calixte Denizet
7cebdbd58c XFA - Fix lot of layout issues
- I thought it was possible to rely on browser layout engine to handle layout stuff but it isn't possible
    - mainly because when a contentArea overflows, we must continue to layout in the next contentArea
    - when no more contentArea is available then we must go to the next page...
    - we must handle breakBefore and breakAfter which allows to "break" the layout to go to the next container
  - Sometimes some containers don't provide their dimensions so we must compute them in order to know where to put
    them in their parents but to compute those dimensions we need to layout the container itself...
  - See top of file layout.js for more explanations about layout.
  - fix few bugs in other places I met during my work on layout.
2021-05-25 17:51:36 +02:00
Jonas Jenwald
9ad7746118 Replace a couple of standard for-loops with for...of in src/display/font_loader.js 2021-05-25 14:11:57 +02:00
Jonas Jenwald
dcbb23d7fa Re-factor FontFaceObject.getPathGenerator to use Arrays instead of strings
This is similar to a lot of other code, where we use "Array + join" rather than repeated string concatenation.
2021-05-25 14:11:54 +02:00
Jonas Jenwald
ec3bcadf56 Enable the unicorn/no-array-push-push ESLint plugin rule
There's generally speaking no need to use multiple consecutive `Array.prototype.push()` calls, since that method accepts multiple arguments, and this ESLint rule helps enforce that pattern.

Please see https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/no-array-push-push.md for additional information.
2021-05-25 13:54:46 +02:00
dependabot[bot]
4f853f7669
Bump browserslist from 4.16.3 to 4.16.6
Bumps [browserslist](https://github.com/browserslist/browserslist) from 4.16.3 to 4.16.6.
- [Release notes](https://github.com/browserslist/browserslist/releases)
- [Changelog](https://github.com/browserslist/browserslist/blob/main/CHANGELOG.md)
- [Commits](https://github.com/browserslist/browserslist/compare/4.16.3...4.16.6)

Signed-off-by: dependabot[bot] <support@github.com>
2021-05-24 20:40:00 +00:00
Tim van der Meij
3538ef017f
Merge pull request #13421 from calixteman/no_remote_image
XFA - Don't display images with a href
2021-05-22 16:06:33 +02:00
Tim van der Meij
9127e11022
Merge pull request #13420 from timvandermeij/test-downloadutils
Drop obsolete logic from the `downloadFile` function in `test/downloadutils.js`
2021-05-22 15:58:51 +02:00
Calixte Denizet
209ac5ca57 XFA - Don't display images with a href 2021-05-22 15:09:43 +02:00
Tim van der Meij
99430225b0
Drop obsolete logic from the downloadFile function in test/downloadutils.js
This code is old and predates the improvements we made to the test
manifest to only contain working URLs (either Web Archive or
GitHub/Bugzilla links), so the fallback logic to try the Web Archive is
no longer necessary. This greatly simplifies the function and also
makes sure that we fail directly in case a bad URL is added to the
manifest, instead of having it work "accidentally" because of this
logic, since we want the manifest to be correct at all times (and
otherwise fail loudly).
2021-05-22 14:45:42 +02:00
calixteman
0df1a56619
Merge pull request #13417 from Snuffleupagus/xfa-URL-clone
[XFA] Send URLs as strings, rather than objects (issue 1773)
2021-05-22 14:31:59 +02:00
Tim van der Meij
de680d7777
Merge pull request #13381 from Snuffleupagus/buildFontPaths-ignoreErrors
Handle errors gracefully, in PartialEvaluator.buildFontPaths, when glyph path building fails
2021-05-22 13:06:31 +02:00
Tim van der Meij
92e731011d
Merge pull request #13419 from Snuffleupagus/more-stringToBytes
Use the `stringToBytes` helper function in more places
2021-05-22 13:00:16 +02:00
Jonas Jenwald
53a70244d0 Use the stringToBytes helper function in more places
Rather than manually reimplementing, more-or-less, this functionality in a few spots we can simply use the existing helper function instead.
2021-05-22 12:23:09 +02:00
Jonas Jenwald
ba13bd8c2d [XFA] Send URLs as strings, rather than objects (issue 1773)
Given that `URL`s aren't supported by the structured clone algorithm, see https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API/Structured_clone_algorithm, the document in issue 1773 will cause the browser to throw `DataCloneError: The object could not be cloned.`-errors and nothing will render.
To fix this, we'll instead simply send the stringified version of the `URL` to prevent these errors from occuring.
2021-05-22 11:58:53 +02:00
Jonas Jenwald
c4429bc3f2 Do the isType3Font-check *once*, rather than repeating it, in PartialEvaluator.translateFont
*This is a small piece of clean-up that I happened to notice while browsing the code.*
2021-05-22 11:46:37 +02:00
Jonas Jenwald
68350378c0 Handle errors gracefully, in PartialEvaluator.buildFontPaths, when glyph path building fails
The building of glyph paths, in the `FontRendererFactory`, can fail in various ways for corrupt font data. However, we're currently not attempting to handle any such errors in the evaluator, which means that a single broken glyph *can* prevent an entire page from rendering.

To address this we simply have to pass along, and check, the existing `ignoreErrors` option in `PartialEvaluator.buildFontPaths` similar to the rest of the `PartialEvaluator` code.
2021-05-22 11:46:31 +02:00
Jonas Jenwald
0dba468e60 Don't allow the LoopbackPort to "clone" a URL
Note that `URL`s aren't supported by the structured clone algorithm, see https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API/Structured_clone_algorithm, and any attempt to send a `URL` using `postMessage` is rejected by the browser. Hence, for consistency when workers are disabled, the `LoopbackPort` should obviously also reject any `URL`s.
2021-05-22 10:11:31 +02:00
Tim van der Meij
b2ffebe978
Merge pull request #13416 from calixteman/xfa_config
XFA - Fix wrong function name
2021-05-21 20:33:35 +02:00
Calixte Denizet
8a8879aed2 XFA - Fix wrong function name 2021-05-21 20:25:26 +02:00
Tim van der Meij
d1d9b9043d
Merge pull request #13415 from Snuffleupagus/getDestination-out-of-order
Improve handling of named destinations in out-of-order NameTrees (PR 10274 follow-up)
2021-05-21 20:15:09 +02:00
Tim van der Meij
5fdb12661b
Merge pull request #13408 from Snuffleupagus/zoom-click-blur
Remove focus from the zoom dropdown, when a mouse is used (bug 1300525, issue 4923)
2021-05-21 20:07:35 +02:00
Tim van der Meij
7d9a83012b
Merge pull request #13401 from Snuffleupagus/rm-some-prettier-ignore
Remove some, with Prettier `2.3.0`, unnecessary `// prettier-ignore` comments
2021-05-21 20:03:07 +02:00
Jonas Jenwald
8d5689387b Improve handling of named destinations in out-of-order NameTrees (PR 10274 follow-up)
According to the specification, see https://web.archive.org/web/20210404042322if_/https://www.adobe.com/content/dam/acom/en/devnet/acrobat/pdfs/PDF32000_2008.pdf#G6.2384179, the keys of a NameTree/NumberTree should be ordered.
For corrupt PDF files, which violate this assumption, it's thus possible that trying to lookup a single entry fails.

Previously, in PR 10274, we implemented a fallback that only applies to the "bottom" node of a NameTree/NumberTree, which in general might not actually help for sufficiently corrupt NameTree/NumberTree data.
Instead we remove the current *limited* fallback from `NameOrNumberTree.get`, and defer to the call-site to handle this case explicitly e.g. by using `NameOrNumberTree.getAll` for data where that makes sense. For well-formed documents, these changes should *not* lead to any additional data fetching/parsing.

Finally, as part of these changes, the validation of named destination data is improved in the `Catalog` and a new unit-test is also added.
2021-05-21 15:48:37 +02:00
Jonas Jenwald
6468e1d0cd Remove focus from the zoom dropdown, when a mouse is used (bug 1300525, issue 4923)
This patch fixes the referenced bugs/issues, in a way that won't interfere with keyboard users, assuming that we actually want to fix these old bugs/issues. (If not, we should close them as WONTFIX.)
2021-05-20 15:28:38 +02:00
Jonas Jenwald
1a8d05fdcf Remove some, with Prettier 2.3.0, unnecessary // prettier-ignore comments
To get the maximum benefit from something like Prettier, you obviously don't want to disable the automatic formatting unless absolutely necessary. When we added Prettier there were a number of cases, mostly involving larger Arrays, which required disabling of the automatic formatting for overall readability and/or to not break inline comments.

With changes in Prettier version `2.3.0`, see [the release notes](https://prettier.io/blog/2021/05/09/2.3.0.html#concise-formatting-of-number-only-arrays-10106httpsgithubcomprettierprettierpull10106-10160httpsgithubcomprettierprettierpull10160-by-thorn0httpsgithubcomthorn0), there's now better formatting support for Arrays containing only numbers. Hence we can now remove a number of `// prettier-ignore` comments, and thus get the benefit of automatic formatting in (slightly) more of the code-base.
2021-05-19 11:36:03 +02:00
calixteman
faf6b10939
Merge pull request #13394 from calixteman/xml_parser
Handle PI with no value in xml parser
2021-05-18 11:14:48 +02:00
Calixte Denizet
4544ebf38a Handle PI with no value in xml parser
- an XML PI contains a target and optionally some content (see https://en.wikipedia.org/wiki/Processing_Instruction)
  - the parser expected to always have some content and so it could lead to wrong parsing.
2021-05-18 10:22:18 +02:00