1
0
Fork 0
mirror of https://github.com/mozilla/pdf.js.git synced 2025-04-22 16:18:08 +02:00
Commit graph

6388 commits

Author SHA1 Message Date
calixteman
9d891883b7
Merge pull request #17970 from calixteman/delete_from_xref
Correctly update the xref table when an annotation is deleted
2024-04-22 15:22:01 +02:00
Calixte Denizet
c57a0f38e9 [Editor] Don't show the context menu when resizing 2024-04-19 15:22:46 +02:00
Calixte Denizet
901d995a7e Correctly update the xref table when an annotation is deleted 2024-04-18 21:27:39 +02:00
Calixte Denizet
71ea8499f0 [Editor] Provide an element to render in the annotation layer after a freetext has been edited (bug 1890535) 2024-04-18 13:29:41 +02:00
Tim van der Meij
7290faf840
Merge pull request #17956 from calixteman/jpx_exceptions
[JPX] Throw an exception with the error messages returned by openjpeg
2024-04-16 20:48:23 +02:00
Calixte Denizet
ebcae3014c [JPX] Throw an exception with the error messages returned by openjpeg 2024-04-16 19:02:24 +02:00
Tim van der Meij
c08b09d3b9
Fix JpxImage API issues (PR 17946 follow-up)
This commit changes the `JpxImage.decode` method signature to define the
`ignoreColorSpace` argument as optional with a default value. Note that
we already set this default value in the `getBytes` method of the
`src/core/decode_stream.js` file since this option only seems useful for
certain special cases and therefore shouldn't be mandatory to provide.

Moreover, the JPX fuzzer is changed to use the new `JpxImage` API.
2024-04-16 18:02:47 +02:00
calixteman
12c4119cbd
Merge pull request #17946 from calixteman/openjpeg
[api-minor] Add a jpx decoder based on OpenJPEG 2.5.2
2024-04-16 13:41:58 +02:00
Calixte Denizet
2e83cfbbc1 [api-minor] Add a jpx decoder based on OpenJPEG 2.5.2
The decoder is compiled in WASM:
https://github.com/mozilla/pdf.js.openjpeg

Fixes #17289, #17061, #16485, #13051, #6365, #4648, #12213.
2024-04-16 12:54:36 +02:00
Jonas Jenwald
a41bb40fbb [api-minor] Update the minimum supported Safari version to 16.4
This patch updates the minimum supported browsers as follows:
 - Safari 16.4, which was released on 2023-03-27; see https://developer.apple.com/documentation/safari-release-notes/safari-16_4-release-notes

Nowadays we usually we try, where feasible and possible, to support browsers/environments that are about two years old. The reasons for limiting support to a slightly more recent Safari version include:
 - Safari has always been slower, compared to other browsers, at implementing e.g. new JavaScript features.
 - Trying to provide support for Safari is often difficult, and over the years we have seen *a lot* of bugs that are specific to Safari.
 - Safari is, and has been for many years, only listed as "mostly" supported in the FAQ.
 - This allows us to remove feature-testing, only relevant to Safari, from the main code-base.

By limiting support to only "recent" browsers we reduce the risk of holding back improvements of the built-in Firefox PDF Viewer, and also (significantly) reduce the maintenance/support burden for the PDF.js core contributors.

*Please note:* As always, the minimum supported browser version assumes that a `legacy`-build of the PDF.js library is being used; see https://github.com/mozilla/pdf.js/wiki/Frequently-Asked-Questions#faq-support
2024-04-15 12:44:37 +02:00
Calixte Denizet
acc56491c9 Warn when a non-embedded font has an invalid name
It can be helpful to find out some heuristics when trying
to find a substitution font.
2024-04-12 13:59:18 +02:00
Calixte Denizet
52ea2333b3 Remove the tag for missing font subset when trying to find a substitution
Fixes #17929.
2024-04-11 20:34:28 +02:00
calixteman
77ee914bd6
Merge pull request #17882 from calixteman/bug1889122
Use the string value of the field when calling the Format callback (bug 1889122)
2024-04-10 09:40:54 +02:00
Calixte Denizet
b643c0fcfb Use the string value of the field when calling the Format callback (bug 1889122) 2024-04-09 22:52:11 +02:00
Calixte Denizet
41aaa083df Don't render annotations with a null dimension
Fixes #17906.
2024-04-09 16:03:49 +02:00
calixteman
a208d6bca7
Merge pull request #17903 from calixteman/moved_freetext
[Editor] Avoid calling setTimeout when editing an existing freetext
2024-04-09 09:48:17 +02:00
Calixte Denizet
3b93fdea26 [Editor] Avoid calling setTimeout when editing an existing freetext
The code was added in order to guess if an editor has been moved but
it's simpler to just set a variable when it's dragged or moved with
the keyboard. This way we remove a bit of asynchronicity.
2024-04-08 22:43:39 +02:00
Tim van der Meij
30b65ca067
Merge pull request #17907 from calixteman/fix_draw_ink
[Editor] Don't add an already added editor (bug 1890367)
2024-04-08 20:44:21 +02:00
Calixte Denizet
976ee96aa8 [Editor] Don't add an already added editor (bug 1890367) 2024-04-08 19:50:55 +02:00
Tim van der Meij
d01a0bd0c8
Fix annotation border style parsing by handling empty dash arrays
The PDF specification states that empty dash arrays, i.e. arrays with
zero elements, are in fact valid. In that case the dash array simply
corresponds to a solid, unbroken line. However, this case was erroneously
being flagged as invalid and therefore the annotation was not drawn
because its width was set to zero. This commit fixes the issue by
allowing dash arrays to have a length of zero.
2024-04-08 16:34:27 +02:00
Calixte Denizet
54110de109 [Editor] Remove the mark from the highlight element and set its role to mark (bug 1889623)
Set aria-label to the highlighted text, this way the focus frame is exactly set
on the highlight element and the higlighted text is read.
2024-04-04 18:06:05 +02:00
Calixte Denizet
3f2f98336e Update the current stride before composing when decoding a text region
Fixes #17871.

We do something similar to:
https://source.chromium.org/chromium/chromium/src/+/main:third_party/pdfium/core/fxcodec/jbig2/JBig2_TrdProc.cpp;l=373-379;drc=24c6be6924df3ff585bb63f6aed4e2c81e791fb2
2024-04-03 18:44:50 +02:00
Calixte Denizet
8f5d907a52 Don't translate char codes when platform,encoding isn't (3,0) 2024-04-03 16:08:11 +02:00
Tim van der Meij
2e5282928f
Merge pull request #17854 from Snuffleupagus/rm-PromiseCapability
[api-minor] Replace the `PromiseCapability` with  `Promise.withResolvers()`
2024-04-02 15:21:43 +02:00
Jonas Jenwald
e4d0e84802 [api-minor] Replace the PromiseCapability with Promise.withResolvers()
This replaces our custom `PromiseCapability`-class with the new native `Promise.withResolvers()` functionality, which does *almost* the same thing[1]; please see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/withResolvers

The only difference is that `PromiseCapability` also had a `settled`-getter, which was however not widely used and the call-sites can either be removed or re-factored to avoid it. In particular:
 - In `src/display/api.js` we can tweak the `PDFObjects`-class to use a "special" initial data-value and just compare against that, in order to replace the `settled`-state.
 - In `web/app.js` we change the only case to manually track the `settled`-state, which should hopefully be OK given how this is being used.
 - In `web/pdf_outline_viewer.js` we can remove the `settled`-checks, since the code should work just fine without it. The only thing that could potentially happen is that we try to `resolve` a Promise multiple times, which is however *not* a problem since the value of a Promise cannot be changed once fulfilled or rejected.
 - In `web/pdf_viewer.js` we can remove the `settled`-checks, since the code should work fine without them:
     - For the `_onePageRenderedCapability` case the `settled`-check is used in a `EventBus`-listener which is *removed* on its first (valid) invocation.
     - For the `_pagesCapability` case the `settled`-check is used in a print-related helper that works just fine with "only" the other checks.
 - In `test/unit/api_spec.js` we can change the few relevant cases to manually track the `settled`-state, since this is both simple and *test-only* code.

---
[1] In browsers/environments that lack native support, note [the compatibility data](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/withResolvers#browser_compatibility), it'll be polyfilled via the `core-js` library (but only in `legacy` builds).
2024-04-01 11:42:37 +02:00
Jonas Jenwald
3d2eb36e27
Merge pull request #17858 from Snuffleupagus/issue-17848
Ensure that Mesh /Shadings have non-zero width/height (issue 17848)
2024-03-30 21:59:58 +01:00
Jonas Jenwald
07a8836ab2 Ensure that Mesh /Shadings have non-zero width/height (issue 17848) 2024-03-29 22:58:25 +01:00
Calixte Denizet
136c1faa7f Display outlines even if one has no title
Fixes #17856.
2024-03-29 21:30:24 +01:00
Tim van der Meij
55db43966e
Merge pull request #17847 from Snuffleupagus/issue-17846
Add better support for /Launch actions with /FileSpec dictionaries (issue 17846)
2024-03-28 13:03:01 +01:00
Calixte Denizet
2dbd7acc41 [Editor] Correctly handle lines when pasting some text in a freetext 2024-03-27 17:48:43 +01:00
Jonas Jenwald
0d039937f9 Add better support for /Launch actions with /FileSpec dictionaries (issue 17846) 2024-03-26 20:15:48 +01:00
calixteman
ad791cc462
Merge pull request #17835 from calixteman/annotation_alt_text
Add alternative text to annotation if any
2024-03-25 16:40:06 +01:00
Jonas Jenwald
90dfe52a76
Merge pull request #17830 from Snuffleupagus/path2d-new-polyfill
Update the `Path2D` polyfill for Node.js environments
2024-03-25 14:58:08 +01:00
Calixte Denizet
d5a0e557c2 [Editor] Fix undoing an editor deletion (bug 1886959)
The original bug was because the parent was null when trying to show
an highlight annotation which led to an exception.
That led me to think about having some null/non-null parent when removing
an editor: it's a mess especially if a destroyed parent is still attached
to an editor. Consequently, this patch always sets the parent to null when
deleting the editor.
2024-03-25 14:17:40 +01:00
Calixte Denizet
a520ad4633 Add alternative text to annotation if any 2024-03-25 13:35:54 +01:00
Jonas Jenwald
dc0df0a3c2 Update the Path2D polyfill for Node.js environments
The polyfill that we use was recently split into two packages, and it now consists of a "core" package and a browser-specific package that build upon the former.
Hence we need to update to use the "core" package, and slightly tweak the code that loads/initializes the polyfill; see also https://www.npmjs.com/package/path2d

This patch was tested successfully with the [pdf2png example](https://github.com/mozilla/pdf.js/tree/master/examples/node/pdf2png), after running `gulp dist-install` locally, using [this PDF document](https://bug810214.bmoattachments.org/attachment.cgi?id=9254990) which contains Type3-fonts that render using `Path2D`.
2024-03-24 12:09:21 +01:00
Calixte Denizet
63c1c787b4 [Editor] Add a label to the highight floating button readable with NVDA (bug 1886964) 2024-03-23 16:12:03 +01:00
Calixte Denizet
a3873e4c68 Don't hide the editor layer when rotating (follow-up of #17802)
Before the patch in #17802, the layer was made visible when calling updateMode
after the rotation angle was set.
2024-03-19 18:36:55 +01:00
Calixte Denizet
1b00511301 [Editor] Make the text layer focusable before the editors (bug 1881746)
Keep the different layers in a constant order to avoid the use of a z-index
and a tab-index.
2024-03-19 16:14:55 +01:00
Jonas Jenwald
0022310b9c
Merge pull request #17706 from Snuffleupagus/Node-Fetch-API
[api-minor] Use the Fetch API, when supported, to load PDF documents in Node.js environments
2024-03-19 11:04:28 +01:00
calixteman
a142c8c945
Merge pull request #17802 from calixteman/fix_tests
[Editor] Fix the rect used to click in some freetext integration tests
2024-03-19 10:50:34 +01:00
Calixte Denizet
5437199c95 [Editor] Fix the rect used to click in some freetext integration tests
And avoid to uselessly set the pointer listeners in the annotation editor layer.
2024-03-18 10:29:32 +01:00
Calixte Denizet
9c3471dd01 Don't render corrupted inlined images
Fixes #17794.
2024-03-15 15:33:18 +01:00
Jonas Jenwald
e650b95253
Merge pull request #17714 from Snuffleupagus/Node-fs-promise
Use `fs/promises` in the Node.js-specific code in the `src/`-folder
2024-03-12 18:09:33 +01:00
Calixte Denizet
b4267cd294 [Editor] Add a floating button close to the selected text to highlight it (bug 1867742)
For now keep this feature behind a pref in order to make some experiments before
deciding to enable it.
2024-03-12 15:06:46 +01:00
Jonas Jenwald
70b6ddc5d9 Move the /SetOCGState handling into the OptionalContentConfig class (PR 15377 follow-up)
This helps ensure that /SetOCGState actions always take the `Usage` dictionary into account as expected.
2024-03-12 13:18:15 +01:00
Jonas Jenwald
3c78ff5fb0 [api-minor] Implement basic support for OptionalContent Usage dicts (issue 5764, bug 1826783)
The following are some highlights of this patch:
 - In the Worker we only extract a *subset* of the potential contents of the `Usage` dictionary, to avoid having to implement/test a bunch of code that'd be completely unused in the viewer.

 - In order to still allow the user to *manually* override the default visible layers in the viewer, the viewable/printable state is purposely *not* enforced during initialization in the `OptionalContentConfig` constructor.

 - Printing will now always use the *default* visible layers, rather than using the same state as the viewer (as was the case previously).
   This ensures that the printing-output will correctly take the `Usage` dictionary into account, and in practice toggling of visible layers rarely seem to be necessary except in the viewer itself (if at all).[1]

---
[1] In the unlikely case that it'd ever be deemed necessary to support fine-grained control of optional content visibility during printing, some new (additional) UI would likely be needed to support that case.
2024-03-12 13:18:15 +01:00
Calixte Denizet
f676c2c0c8 [Editor] Improve the accessibility of the highlight editor (bug 1881743) 2024-03-11 14:21:43 +01:00
calixteman
fb9e438442
Merge pull request #17781 from calixteman/stamp_altext_button_cp
[Editor] Make sure the alt-text button is there when pasting an image from an other tab
2024-03-07 21:44:53 +01:00
Calixte Denizet
0f8dda1af0 [Editor] Make sure the alt-text button is there when pasting an image from an other tab 2024-03-07 18:24:34 +01:00