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

20281 commits

Author SHA1 Message Date
Hamir Mahal
d8b6f1138f
Replace uninformative README badge (issue 19406) 2025-02-01 15:32:09 -08:00
Tim van der Meij
8babcded5d
Centralize the editor selector definitions in the highlight editor integration tests
In most integration tests we already use the pattern of defining the
editor selector once and reusing it in the rest of the test, but it's
not fully consistent everywhere yet. This commit fixes that for the
highlight editor integration tests, which has multiple advantages:

- it improves consistency between the various editor integration tests;
- it removes duplicate function calls and aligns variable definitions;
- it reduces the number of `getEditorSelector` calls that contained
  hardcoded IDs, which helps to isolate the tests and to simplify
  follow-up patches.
2025-02-01 19:23:42 +01:00
Tim van der Meij
0326814a1e
Update translations to the most recent versions 2025-02-01 18:37:01 +01:00
Tim van der Meij
c0957986b7
Update dependencies to the most recent versions 2025-02-01 18:35:56 +01:00
Tim van der Meij
de191d2a12
Merge pull request #19402 from Snuffleupagus/AnnotationElement-width-height-getters
Add width/height getters in the `AnnotationElement` class
2025-02-01 16:17:59 +01:00
Jonas Jenwald
2fd1344ece Add width/height getters in the AnnotationElement class
This is similar to PR 19397, but for the main-thread code, and helps to slightly shorten the code.
2025-02-01 13:20:15 +01:00
Jonas Jenwald
c8be02f2a7 [api-minor] Simplify the TextLayer.#getAscent fallback (PR 12896 follow-up)
At the time of PR 12896 the `fontBoundingBox{Ascent, Descent}` properties were not yet available by default in Fírefox, however that's no longer the case since Firefox 116; please see https://bugzilla.mozilla.org/show_bug.cgi?id=1801198.

Hence this patch which replaces the "full" fallback with a warning and uses the `ascent`/`descent` values from the fonts in the PDF document (as we did previously). Obviously the TextLayer won't look as good in that case, but it's a simpler and shorter solution.
2025-02-01 10:11:57 +01:00
Tim van der Meij
b48717a99e
Merge pull request #19397 from Snuffleupagus/Annotation-width-height-getters
Add width/height getters in the `Annotation` class
2025-01-31 16:14:02 +01:00
calixteman
938add1bb0
Merge pull request #19396 from calixteman/update_signature_draw
[Editor] Add some functions in order to extract contours from text and to generate a drawing from a drawn signature
2025-01-31 15:44:00 +01:00
Calixte Denizet
20992e87f5 [Editor] Add some functions in order to extract contours from text and to generate a drawing from a drawn signature 2025-01-31 14:59:58 +01:00
Jonas Jenwald
6f2966628c Add width/height getters in the Annotation class
Currently we're manually computing the width/height of the /Rect-entry in a number of spots throughout the worker-thread Annotation code, which these new getters help avoid.
2025-01-31 13:21:53 +01:00
calixteman
58c8f069f7
Merge pull request #19395 from calixteman/fix_overlay_manager
Avoid to remove the active overlay when a cancelled dialog (like the file picker) was called from a dialog
2025-01-30 16:51:26 +01:00
calixteman
ec7270c546
Merge pull request #19394 from calixteman/mv_supported_img_types
Move the array containing the supported image mime types in display_utils
2025-01-30 16:48:13 +01:00
Calixte Denizet
eca1e6c52e Avoid to remove the active overlay when a cancelled dialog (like the file picker) was called from a dialog 2025-01-30 16:13:48 +01:00
Calixte Denizet
2c737bc420 Move the array containing the supported image mime types in display_utils
and make it available for the viewer (it'll be used in the signature UI).
2025-01-30 15:35:17 +01:00
Jonas Jenwald
31deee26b9
Merge pull request #19393 from Snuffleupagus/fewer-hasFieldFlag
Use fewer `hasFieldFlag` calls in the `src/core/annotation.js` file
2025-01-30 15:10:14 +01:00
Jonas Jenwald
d1a0f3e495
Merge pull request #19392 from Snuffleupagus/image-options-init-once
Initialize the image-options, on the worker-thread, once per document
2025-01-30 15:06:25 +01:00
Jonas Jenwald
9e227de3c5 Use fewer hasFieldFlag calls in the src/core/annotation.js file
We lookup a number of field-flags multiple times, which seems unnecessary.
2025-01-30 13:38:57 +01:00
Jonas Jenwald
db53320da8 Initialize the image-options, on the worker-thread, once per document
Currently we're initializing the image-options for every page, which seems unnecessary since it should suffice to do that once per document.

Also, changes the `BasePdfManager` constructor to improve readability/documentation a little bit.
2025-01-30 11:52:15 +01:00
calixteman
42c2b7b657
Merge pull request #19339 from calixteman/signature_tools
[Editor] (WIP) Add a new tool in order to add an handwritten signature to a pdf (bug 1942343)
2025-01-30 10:54:56 +01:00
Calixte Denizet
2f828c7bf4 [Editor] (WIP) Add a new tool in order to add an handwritten signature to a pdf (bug 1942343)
This patch is adding some code in order to extract a drawing as curves from an image.
The algorithm is basically the following:
 - reduce the dimensions
 - make it gray
 - apply a bilateral filter in order to add some blurryness while keeping the edges
 - compute the histogram
 - guess what's the background color which should contain a large majority of the pixels
 - make a binary image
 - extract the contours in using the Suzuki algorithm
 - apply the Douglas-Peucker algorithm in order to reduce the number of points

The algorithm is improvable but it should work pretty well if there's a clear difference between
the background and the drawing.
In a v2 we could use a ML model in order to improve the extraction.

There's few changes related to the UI in order to make the tool usable, but they're very basic
for the moment.
2025-01-29 21:52:14 +01:00
Jonas Jenwald
9bc4331485
Merge pull request #19390 from Snuffleupagus/issue-19389
Support the password field-flag in TextWidgetAnnotation (issue 19389)
2025-01-29 14:41:19 +01:00
Jonas Jenwald
6f2706fad6 Support the password field-flag in TextWidgetAnnotation (issue 19389) 2025-01-29 12:40:09 +01:00
Jonas Jenwald
786ac2fe01
Merge pull request #19388 from Snuffleupagus/readInt16
Introduce a `readInt16` helper function in the `src/core/core_utils.js` file
2025-01-29 11:42:59 +01:00
Jonas Jenwald
237a17ad56 Introduce a readInt16 helper function in the src/core/core_utils.js file
Rather than manually repeating code needed to get an int16, we can move and re-use an existing helper function instead.
2025-01-29 10:14:23 +01:00
Jonas Jenwald
b0b9552216
Merge pull request #19384 from Snuffleupagus/isNumberArray-fix-BigInt-check
Handle *empty* BigInt64Array/BigUint64Array in the `isNumberArray` helper
2025-01-28 10:05:01 +01:00
Jonas Jenwald
6281a89778 Handle *empty* BigInt64Array/BigUint64Array in the isNumberArray helper
The current checks would accidentally allow *empty* BigInt64Array/BigUint64Array, which we can fix by instead checking directly for those types.
This should be fine since those types are available in all environments that we support, see:
 - https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/BigInt64Array#browser_compatibility
 - https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/BigUint64Array#browser_compatibility
2025-01-27 12:57:47 +01:00
Tim van der Meij
4f1078dc63
Merge pull request #19368 from Snuffleupagus/rm-delayed-cleanup
[api-minor] Simplify clean-up of page resources after rendering
2025-01-26 16:54:43 +01:00
Tim van der Meij
09a0a0f06f
Merge pull request #19358 from Snuffleupagus/Node-enable-web_pdfjsLib
Enable the "checks that the viewer re-exports the expected API functionality" unit-test in Node.js
2025-01-26 16:45:51 +01:00
Tim van der Meij
329c3d1d71
Merge pull request #19381 from Snuffleupagus/rm-isInEditingMode
Remove unused `isInEditingMode` method (PR 19311 follow-up)
2025-01-26 16:44:21 +01:00
Tim van der Meij
3cfc41e54d
Merge pull request #19382 from mozilla/dependabot/npm_and_yarn/undici-6.21.1
Bump undici from 6.19.8 to 6.21.1
2025-01-26 16:43:11 +01:00
dependabot[bot]
85a6c1ea6b
Bump undici from 6.19.8 to 6.21.1
Bumps [undici](https://github.com/nodejs/undici) from 6.19.8 to 6.21.1.
- [Release notes](https://github.com/nodejs/undici/releases)
- [Commits](https://github.com/nodejs/undici/compare/v6.19.8...v6.21.1)

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

Signed-off-by: dependabot[bot] <support@github.com>
2025-01-26 15:37:40 +00:00
Jonas Jenwald
b02274e5d6 Remove unused isInEditingMode method (PR 19311 follow-up)
This method was added in PR 19311, however it's not actually used anywhere in the code-base.
2025-01-25 13:17:25 +01:00
calixteman
38800715cd
Merge pull request #19373 from Hydraulicus/fix-drawing-beyond-page
[Editor] Add validation for the target element of curve endpoints
2025-01-23 23:54:37 +01:00
Jonas Jenwald
4a513bb52e
Merge pull request #19365 from Snuffleupagus/viewer-component-render-option-objects
[api-major] Change viewer component `render`-methods to take parameter objects
2025-01-23 22:36:28 +01:00
calixteman
f798bade4e
Merge pull request #19338 from avdoseferovic/fix/ink-editor-jumping
[Editor] Don't scroll when drawing (issue 17327)
2025-01-23 22:07:29 +01:00
hydraulicus
104e1c3f90 [Editor] Add validation for the target element of curve endpoints
This patch fixes a bug that caused incorrect curve shapes when an endpoint lies beyond the page boundaries. It adds a check for the endpoint's position, and if it is outside the page, the point is excluded from the shape's coordinates.
2025-01-23 22:05:33 +02:00
Jonas Jenwald
30fa7c3d84
Merge pull request #19372 from Snuffleupagus/mainHighlightColorPicker-toolbar-init
[GENERIC viewer] Re-initialize the viewer-toolbar `ColorPicker` for each PDF document
2025-01-23 18:08:02 +01:00
Jonas Jenwald
342b5e20b4 [GENERIC viewer] Re-initialize the viewer-toolbar ColorPicker for each PDF document
Steps to reproduce this in `master`:
 1. Open https://mozilla.github.io/pdf.js/web/viewer.html
 2. Use the "Open"-button (in the secondaryToolbar), or drag-and-drop, to load another PDF document.
 3. Enable the highlight-editor.
 4. Try to pick a new colour.

Note how it's no longer possible to change the default highlight-colour.
The reason for this is that we're only initializing the viewer-toolbar `ColorPicker` *once*, which doesn't work since every PDF document gets its own `AnnotationEditorUIManager`-instance. To address this we simply need to re-initialize the viewer-toolbar `ColorPicker`, and note that this patch won't affect the Firefox PDF Viewer.
2025-01-23 16:53:31 +01:00
Jonas Jenwald
2132552d71
Merge pull request #19371 from Snuffleupagus/issue-19369
[Editor] Ensure that `highlightSelection` waits until we've fully updated the editing-mode (issue 19369)
2025-01-23 14:39:35 +01:00
Jonas Jenwald
3b4758a400 [Editor] Ensure that highlightSelection waits until we've fully updated the editing-mode (issue 19369)
With the changes in PR 18843 the `AnnotationEditorUIManager.prototype.updateMode` method is now asynchronous, which we need to take into account when dispatching the "annotationeditormodechanged" event.
2025-01-23 13:46:39 +01:00
Jonas Jenwald
9241e1be8c [api-minor] Simplify clean-up of page resources after rendering
After PR 2317, which landed in 2012, we'd immediately clean-up after rendering for pages with large image resources. This had the effect that re-rendering, e.g. after zooming, would force us to re-parse the entire page which could easily lead to bad performance.
In PR 16108, which landed in 2023, we tried to lessen the impact of that by slightly delaying clean-up however that's obviously not a perfect solution (and it increased the complexity of the relevant code).

Furthermore, the condition for this "immediate" clean-up seems a bit arbitrary to me since a page could easily contain a large number of smaller images whose total size vastly exceeds the threshold.

Hence this patch, which suggests that we remove the conditional and delayed clean-up after rendering. Compared to the situation back in 2012, a number of things have improved since:
 - We have *multiple* caches for repeated image-resources on the worker-thread[1], which helps reduce overall memory usage and improves performance.
 - We downsize huge images on the worker-thread, which means that the images we're using on the main-thread cannot be arbitrarily large.
 - The amount of available RAM on devices should be a lot higher, since more than a decade has passed.

A future improvement here, for more resource constrained environments, could be to instead clean-up when actually needed using e.g. `WeakRef`s (see issue 18148).

---
[1] More specifically:
 - `LocalImageCache`, which caches image-data by /Name and /Ref on the `PartialEvaluator.prototype.getOperatorList` level.
 - `RegionalImageCache`, which caches image-data by /Ref on the `PartialEvaluator`-instance (i.e. at the page) level.
 - `GlobalImageCache`, which caches image-data by /Ref globally at the document level.
2025-01-22 12:19:44 +01:00
Jonas Jenwald
7450457525 [api-major] Change viewer component render-methods to take parameter objects
This is nicer than a bunch of somewhat arbitrarily ordered parameters, and makes any future changes easier.
2025-01-21 23:29:45 +01:00
calixteman
877f69886c
Merge pull request #19361 from calixteman/issue19360
Correctly render the glyph outline when it has a stroke pattern
2025-01-21 16:41:26 +01:00
Calixte Denizet
1ccf6ed976 Correctly render the glyph outline when it has a stroke pattern
It fixes #19360.

Each glyph in the test case has a fill and a stroke pattern, so the current transform used
to scale the glyph outline must be the same.
In setting the stroke color to green, I noticed that the last outline contains some non-closed
subpaths, so when generating the glyph outline, every time we 'moveTo', we close the previous
subpath.
2025-01-21 15:30:16 +01:00
Jonas Jenwald
79a976ce9d
Merge pull request #19337 from Snuffleupagus/dev-wasm
Support multiple wasm-files in the development viewer
2025-01-21 10:50:17 +01:00
Jonas Jenwald
23dc3ff49f
Merge pull request #19353 from Snuffleupagus/ESLint-import/no-restricted-paths
Enable the `import/no-restricted-paths` ESLint plugin rule for the viewer
2025-01-20 22:28:50 +01:00
Jonas Jenwald
0790d94674 Enable the "checks that the viewer re-exports the expected API functionality" unit-test in Node.js
By also running `gulp generic-legacy` before the Node.js unit-tests, we can enable one more test-case in Node.js environments.
2025-01-20 22:10:36 +01:00
Jonas Jenwald
850e605e36
Merge pull request #19356 from Snuffleupagus/bug-1942064-2
Replace the EXIF-block with dummy data to prevent JPEG images being rotated (bug 1942064)
2025-01-20 16:54:09 +01:00
Jonas Jenwald
c4ba3ac23f Replace the EXIF-block with dummy data to prevent JPEG images being rotated (bug 1942064)
The `ImageDecoder` will respect the EXIF orientation, which can lead to JPEG images being incorrectly rotated. To avoid this we replace the entire EXIF-block with dummy data, which works since it'll cause EXIF parsing to bail out early in Firefox; see https://searchfox.org/mozilla-central/rev/9a66d18cb35595c89f499a1011c9dd7e573fce77/image/decoders/EXIF.cpp#130-138
2025-01-20 16:50:22 +01:00