7486 Commits

Author SHA1 Message Date
calixteman
baf8647b1f
Add the possibility to merge/update acroforms when merging/extracting (bug 2015853) 2026-03-07 19:03:02 +01:00
Tim van der Meij
688ae9b3e5
Merge pull request #20811 from calixteman/fix_xref
Add fetch** functions in the XRefWrapper
2026-03-05 22:02:08 +01:00
Tim van der Meij
01bc76e681
Merge pull request #20806 from Snuffleupagus/BinaryCMapStream-extends-Stream
Let `BinaryCMapStream` extend the `Stream` class
2026-03-05 20:43:37 +01:00
Calixte Denizet
150c1e80c2
Add fetch** functions in the XRefWrapper
It could fail to not have them if they're used during writing.
2026-03-05 19:21:12 +01:00
Jonas Jenwald
fccee4bffd Let BinaryCMapStream extend the Stream class
Looking at the `BinaryCMapStream` implementation, it's basically a "regular" `Stream` but with added functionality for reading compressed CMap data.
Hence, by letting `BinaryCMapStream` extend `Stream`, we can remove an effectively duplicate method and simplify/shorten the code a tiny bit.
2026-03-05 11:45:29 +01:00
Jonas Jenwald
aa445877a9 Use BaseStream.prototype.getString in the readPostScriptTable function
Currently the `customNames` are read one byte at a time, in a loop, and at every iteration converted to a string.
This can be replaced with the `BaseStream.prototype.getString` method, which didn't exist back when this function was written.
2026-03-04 18:34:07 +01:00
Jonas Jenwald
4d0709c174
Merge pull request #20795 from Snuffleupagus/Dict-more-iterators
Change the `Dict.prototype.{getKeys, getRawValues}` methods to return iterators
2026-03-04 18:26:42 +01:00
calixteman
7384359a41
Merge pull request #20781 from pengkunbin/fix/chinese-font-names-gbk
Fix missing Chinese font name variants (SimFang and XiaoBiaoSong) in GBK encoding detection
2026-03-04 16:49:44 +01:00
Jonas Jenwald
229e3642be Change the Dict.prototype.getRawValues method to return an iterator
This method is usually used with loops, and it should be a tiny bit more efficient to use an iterator directly rather than first iterating through ` Map`-values to create a temporary `Array` that we finally iterate through at the call-site.

Note that the `getRawValues` method is old code, and originally the `Dict` class stored its data in a regular `Object`, hence why the old code was written that way.
2026-03-04 16:07:49 +01:00
Jonas Jenwald
58996f21b2 Change the Dict.prototype.getKeys method to return an iterator
This method is usually used with loops, and it should be a tiny bit more efficient to use an iterator directly rather than first iterating through ` Map`-keys to create a temporary `Array` that we finally iterate through at the call-site.

Note that the `getKeys` method is old code, and originally the `Dict` class stored its data in a regular `Object`, hence why the old code was written that way.
2026-03-04 16:07:49 +01:00
Jonas Jenwald
40bd73551c
Merge pull request #20793 from Snuffleupagus/more-getRawEntries
Use the `Dict.prototype.getRawEntries` method more
2026-03-04 16:05:57 +01:00
calixteman
ce5f34ba13
Merge pull request #20780 from wooorm/wooorm/dismiss-popups
Add support for dismissing comment popups with click outside
2026-03-04 15:24:29 +01:00
calixteman
72f98d4e00
Merge pull request #20788 from calixteman/organize_context_menu
Add the pages organization actions in the Firefox context menu (bug 2018138)
2026-03-04 15:20:00 +01:00
Jonas Jenwald
50d66d7d34 Use the Dict.prototype.getRawEntries method more
This changes a number of loops currently using `Dict.prototype.{getKeys, getRaw}`, since it should be a tiny bit more efficient to use an iterator directly rather than first iterating through `Map`-keys to create a temporary `Array` that we finally iterate through at the call-site.

Note that the `getKeys` method is much older than `getRawEntries`, and originally the `Dict` class stored its data in a regular `Object`, hence why the old code was written that way.
2026-03-04 12:46:25 +01:00
Nicolò Ribaudo
2f2d5c9e27
Add script to check license headers 2026-03-04 10:40:39 +01:00
Calixte Denizet
d90530b86c
Add the pages organization actions in the Firefox context menu (bug 2018138) 2026-03-04 09:02:39 +01:00
Calixte Denizet
a474e81b8a
Add a way to extract some pages from a pdf (bug 2019682)
The user has to select some pages and then click on the "Save As" menu item in the Manage menu.
If they modify the structure of the pdf (deleted, moved, copied pages), they have to use the usual
save button.
2026-03-03 21:39:13 +01:00
Titus Wormer
8b4f9048cf
Add support for dismissing comment popups with click outside
This solves [bug 1989406](https://bugzilla.mozilla.org/show_bug.cgi?id=1989406).
(“The user should be able to dismiss the in-content message displayed by clicking somewhere else in the PDF”)
There’s a good gif there that shows the problematic behavior.

In the thread, there are also mentions of 2 similar but slightly separate problems:

* clicking on another highlight should also dismiss
* the mention that hitting the escape key does not dismiss

I found the last point, the escape key, to work already (first test case here).
But this PR solves the main bug (second test case) and the adjacent one
(third test case).
It works by using the existing `unselectAll` handling.
2026-03-03 11:14:22 +01:00
jizou
0e1b5cd7bb Fix missing Chinese font name variants (SimFang and XiaoBiaoSong) in GBK encoding detection 2026-03-03 17:04:59 +08:00
Tim van der Meij
f32b9d2677
Merge pull request #20738 from Snuffleupagus/function-shorten
Slightly shorten some code in the `src/core/function.js` file
2026-03-01 20:06:29 +01:00
Jonas Jenwald
86573cc995
Merge pull request #20757 from Snuffleupagus/getPdfFilenameFromUrl-fix-decode-regex
Fix the broken regular expression in the `decode` helper in the `getPdfFilenameFromUrl` function (issue 20664)
2026-02-27 23:14:18 +01:00
calixteman
9c3a752388
Merge branch 'master' into scientific 2026-02-27 18:39:44 +01:00
Jonas Jenwald
e3a7c0779d Fix the broken regular expression in the decode helper in the getPdfFilenameFromUrl function (issue 20664)
This will ignore filenames that become effectively empty, i.e. ones that are only ".pdf" and nothing more.

*Please note:* While this passes all existing unit-tests, I don't know if this is necessarily the "correct" solution here.
2026-02-27 15:19:43 +01:00
Jeff Muizelaar
8fa6ef36e4 Remove scientific notation parsing.
This behaviour comes from the initial pdf.js commit but is wrong and
doesn't match other PDF readers like muPDF or pdfium.

From PDF Spec 7.3.3:

A PDF writer shall not use the PostScript language syntax for numbers with non-decimal radices (such
as 16#FFFE) or in exponential format (such as 6.02E23).
2026-02-26 20:22:34 -05:00
Jonas Jenwald
8ced999803 Slightly shorten some code in the src/core/function.js file 2026-02-26 10:42:56 +01:00
Jonas Jenwald
82fc2c94f0 Include transfers correctly in the "GetOperatorList" message (PR 16588 follow-up)
Currently the transfers aren't actually being used with the "GetOperatorList" message, since the placement of the parameter is wrong; note the method signature: 909a700afa/src/shared/message_handler.js (L219-L229)
This goes back to PR 16588, which added the transfers parameter, and unfortunately we all missed that :-(

Simply fixing the parameter isn't enough however, since that broke printing of Stamp-editors (and possibly others). The solution here is to *not* transfer data during printing, given that a single `PrintAnnotationStorage` instance is being used for all pages.
2026-02-25 15:55:43 +01:00
Jonas Jenwald
80db3609f4 Remove unused lastCode property from the LZWStream class (PR 324 follow-up)
This appear to have been unused already in PR 324 all the way back in 2011.
2026-02-25 13:31:44 +01:00
Tim van der Meij
4ecbd0cbe2
Merge pull request #20726 from Snuffleupagus/getOrInsertComputed-fewer-functions
Reduce allocations and function creation when using `getOrInsert` and `getOrInsertComputed`
2026-02-24 23:32:36 +01:00
Tim van der Meij
b43c8eab73
Merge pull request #20725 from calixteman/bug2018162
After cut & paste, the thumbnail must be correctly rendered (bug 2018162)
2026-02-24 23:27:07 +01:00
Jonas Jenwald
0d4e587a5f Reduce allocations when using Map.prototype.getOrInsert() with Arrays
Change all these cases to use `Map.prototype.getOrInsertComputed()` instead, in combination with a helper function for creating the `Array`s (similar to the previous patch).
2026-02-24 09:03:32 +01:00
Jonas Jenwald
2e07715c9d Reduce function creation when using Map.prototype.getOrInsertComputed()
With the exception of the first invocation the callback function is unused, which means that a lot of pointless functions may be created.
To avoid this we introduce helper functions for simple cases, such as creating `Map`s and `Objects`s.
2026-02-24 08:58:28 +01:00
calixteman
15e7a551ab
Reset transfer functions when entering in a new group
It fixes #20722.
2026-02-23 22:37:20 +01:00
Calixte Denizet
97d973ce09
After cut & paste, the thumbnail must be correctly rendered (bug 2018162) 2026-02-23 18:38:33 +01:00
Jonas Jenwald
c2f5e19eb0 Use Map.prototype.getOrInsertComputed() in the src/core/xfa/ folder 2026-02-22 22:57:50 +01:00
Jonas Jenwald
e2c8fc6140 Use Map.prototype.getOrInsertComputed() in the src/display/api.js file 2026-02-22 21:01:13 +01:00
Jonas Jenwald
c81904ac0a Use Map.prototype.getOrInsertComputed() in the src/display/canvas.js file 2026-02-22 17:55:51 +01:00
Jonas Jenwald
ab8e67ecff Use Map.prototype.getOrInsert() in the src/display/annotation_layer.js file 2026-02-22 17:54:17 +01:00
Jonas Jenwald
bfe265ad31 Use Map.prototype.getOrInsertComputed() in the editorStats getter 2026-02-22 15:10:02 +01:00
Tim van der Meij
cc516d0dd4
Merge pull request #20709 from Snuffleupagus/scripting-unconditional-FinalizationRegistry
Use `FinalizationRegistry` unconditionally in the `src/scripting_api/app.js` file
2026-02-22 14:59:03 +01:00
Tim van der Meij
a5a27a5ca7
Merge pull request #20705 from Snuffleupagus/#collectParents-getOrInsert
Use `Map.prototype.getOrInsert()` in the `#collectParents` method
2026-02-22 12:55:41 +01:00
Tim van der Meij
8189ca358c
Merge pull request #20703 from Snuffleupagus/#collectFieldObjects-getOrInsert
Use `Map.prototype.getOrInsert()` in the `#collectFieldObjects` method
2026-02-22 12:39:54 +01:00
Jonas Jenwald
ad0a310394
Merge pull request #20706 from Snuffleupagus/ensureDebugMetadata-getOrInsertComputed
Use `Map.prototype.getOrInsertComputed()` in the `ensureDebugMetadata` helper
2026-02-22 10:35:44 +01:00
Jonas Jenwald
2631750038
Merge pull request #20702 from Snuffleupagus/getNewAnnotationsMap-getOrInsert
Use `Map.prototype.getOrInsert()` in the `getNewAnnotationsMap` helper
2026-02-22 10:29:33 +01:00
Jonas Jenwald
956eb10329 Use FinalizationRegistry unconditionally in the src/scripting_api/app.js file
After the QuickJS update in PR 20708 this code can now be simplified.
2026-02-21 22:37:30 +01:00
Jonas Jenwald
0d8bc689b9 Add missing license header in src/display/canvas_dependency_tracker.js 2026-02-21 13:26:20 +01:00
Jonas Jenwald
c7bdf5b508 Use Map.prototype.getOrInsertComputed() in the ensureDebugMetadata helper
Also, shorten the function by using optional chaining.
2026-02-21 12:02:45 +01:00
Jonas Jenwald
3e7ad8d6bf Use Map.prototype.getOrInsert() in the #collectParents method 2026-02-21 11:42:42 +01:00
Jonas Jenwald
210c969c4c Use Map.prototype.getOrInsert() in the #collectFieldObjects method 2026-02-21 11:23:32 +01:00
Jonas Jenwald
76a5aed05f Use Map.prototype.getOrInsert() in the getNewAnnotationsMap helper 2026-02-21 11:03:00 +01:00
Jonas Jenwald
350f3fa7e5 Slightly shorten some code in the src/scripting_api/ folder
- Use nullish coalescing assignment more.
 - Use ternary expressions more.
2026-02-20 22:47:22 +01:00