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

20686 commits

Author SHA1 Message Date
calixteman
13474aca63
Merge pull request #19620 from calixteman/cmyk_icc
[api-minor] Use an icc profile for converting CMYK to RGB
2025-03-10 16:55:48 +01:00
Jonas Jenwald
4152eae3fb
Merge pull request #19635 from Snuffleupagus/thumbnails-maxCanvasPixels
Support the `maxCanvasPixels` option in the thumbnails code
2025-03-10 16:30:25 +01:00
Jonas Jenwald
26b5c8f821
Merge pull request #19625 from Snuffleupagus/issue-19624
Improve text-selection for Type3 fonts, using `d0` operators, with empty /FontBBox-entries (issue 19624)
2025-03-10 16:26:04 +01:00
Jonas Jenwald
0edfd29a3e Improve text-selection for Type3 fonts, using d0 operators, with empty /FontBBox-entries (issue 19624)
For Type3 glyphs with `d1` operators it's easy to compute a fallback bounding box, however for `d0` the situation is more difficult.
Given that we nowadays compute the min/max of basic path-rendering operators on the worker-thread, we can utilize that by parsing these Type3 operatorLists to guess a more suitable fallback bounding box.
2025-03-10 16:21:54 +01:00
Jonas Jenwald
b9e8844541
Merge pull request #19613 from Snuffleupagus/issue-19611
Let SMask/Mask images fallback to the parent image dimensions (issue 19611)
2025-03-10 16:12:48 +01:00
Calixte Denizet
7280540901 [api-minor] Use an icc profile for converting CMYK to RGB 2025-03-10 14:18:20 +01:00
Jonas Jenwald
fc22d3afc7 Support the maxCanvasPixels option in the thumbnails code
This addresses an inconsistency in the viewer, since the thumbnails don't respect the `maxCanvasPixels` option.
Note that, as far as I know, this has not lead to any bugs since the thumbnails render with a fixed (and small) width, however it really cannot hurt to address this (especially after the introduction of the `maxCanvasDim` option).

To support this a new `OutputScale`-method was added, to avoid having to duplicate code in multiple files.
2025-03-10 14:12:07 +01:00
Jonas Jenwald
10a99ea0a7 Let SMask/Mask images fallback to the parent image dimensions (issue 19611)
One of the images have a corrupt SMask, where the /Height-entry is bogus; see the excerpt below (via https://brendandahl.github.io/pdf.js.utils/browser/).
```
SMask (stream) [id: 17, gen: 0]

    ColorSpace = /DeviceGray
    Height = /Length
    Subtype = /Image
    Filter = /FlateDecode
    Type = /XObject
    Width = 157
    Matte (array)
    BitsPerComponent = 8
    Length = 3893
    <view contents> download
```

Hence we enable SMask/Mask images to fallback to the parent image dimensions, and also add more validation of the width/height to get a better error message when that data is wrong.
2025-03-10 12:37:44 +01:00
Jonas Jenwald
1bc98dfbd9
Merge pull request #19621 from Snuffleupagus/bug-1943094-thumbs
Limit the maximum thumbnail canvas width/height, similar to pages (PR 19604 follow-up)
2025-03-10 11:32:08 +01:00
Tim van der Meij
81baa16c8b
Merge pull request #19629 from Snuffleupagus/split-crypto
Re-factor the `src/core/crypto.js` file
2025-03-09 13:08:40 +01:00
Tim van der Meij
621258f85c
Merge pull request #19623 from Snuffleupagus/PDFFunctionFactory-rm-createFromArray
Remove the `PDFFunctionFactory.createFromArray` method
2025-03-09 12:58:55 +01:00
Tim van der Meij
66af403f10
Merge pull request #19628 from Snuffleupagus/MathClamp-2
Use the `MathClamp` helper function more (PR 19617 follow-up)
2025-03-09 12:49:53 +01:00
Jonas Jenwald
0a2c176027 Remove the unused or/shiftLeft methods from the Word64 class (PR 4938 follow-up)
These methods were introduced in *the first* commit of PR 4938, however they became unused in *the second* commit of that PR.
Hence it seems that we've been accidentally shipping, a small amount of, unused code for over a decade.
2025-03-08 17:33:16 +01:00
Jonas Jenwald
67065e43f5 Replace loops with TypedArray.prototype.set in the CipherTransformFactory class
Also, adds `TypedArray.prototype.fill` usage in one spot.
2025-03-08 16:17:45 +01:00
Jonas Jenwald
c65f1b0dae Move a couple of AESBaseCipher fields from the constructors
Thanks to modern JS class features we can, ever so slightly, shorten some class field definitions.
2025-03-08 16:06:30 +01:00
Jonas Jenwald
461488cb16 Initialize the defaultPasswordBytes, in CipherTransformFactory, lazily 2025-03-08 16:06:30 +01:00
Jonas Jenwald
139d27aa7d Simplify various calculate... methods a tiny bit
While initializing the `padded` Uint8Arrays we're manually assigning zeros to some entries, which is completely unnecessary since that's the default value for a TypedArray, and instead we can just increment the index.
2025-03-08 16:06:27 +01:00
Jonas Jenwald
facf34606f Move the calculateSHA384 and calculateSHA512 functions into their own file
This allows us to remove a closure, and we also change the code to initialize various constants lazily.
2025-03-08 15:56:22 +01:00
Jonas Jenwald
a1eac86037 Move the calculateSHA256 function into its own file
This allows us to remove a closure, and we also change the code to initialize various constants lazily.
2025-03-08 15:56:16 +01:00
Jonas Jenwald
3e8d01ad7c Move the calculateMD5 function into its own file
This allows us to remove a closure, and we also change the code to initialize various constants lazily.
2025-03-08 15:56:05 +01:00
Jonas Jenwald
1b5151f969 Remove pointless Math.min usage in the XFA parsing
When creating the `StyleMapping` for the "xfa-font-horizontal-scale" and "xfa-font-vertical-scale" properties there's currently pointless `Math.min` usage, since we're not actually comparing with anything.
2025-03-08 12:22:33 +01:00
Jonas Jenwald
bee0f53c65 Use the MathClamp helper function more (PR 19617 follow-up)
There's a few spots that I accidentally missed in PR 19617.
2025-03-08 12:19:56 +01:00
Jonas Jenwald
cef4fcf025
Merge pull request #19622 from nicolo-ribaudo/zoom-detail-view-constant-redraw
Do not constantly render the detail canvas on zoom (bug 1952496)
2025-03-07 13:56:13 +01:00
Nicolò Ribaudo
a1dc46aa9d
Do not constantly render the detail canvas on zoom
When zooming, we should skip rendering the detail canvas until the
zoom is done, similarly to how normal page rendering is delayed.
To do so is enough to skip details view while zooming, since the
main view rendering that already happens after the delay will also
trigger rendering of the detail views.
2025-03-07 12:38:52 +01:00
Jonas Jenwald
17d7943758 Remove the PDFFunctionFactory.createFromArray method
This combines the `PDFFunctionFactory.create` and `PDFFunctionFactory.createFromArray` methods, which helps simplify and shorten the code.
Additionally, to simplify the parameter handling we pass the `PDFFunctionFactory`-instance directly to the various `PDFFunction`-methods.
2025-03-07 12:28:14 +01:00
Jonas Jenwald
eef15a30cd Limit the maximum thumbnail canvas width/height, similar to pages (PR 19604 follow-up)
The changes in PR 19604 weren't enough for thumbnail canvases in some cases, see e.g. https://web.archive.org/web/20231204152348if_/https://user.informatik.uni-bremen.de/cabo/rfc9000.pdf#pagemode=thumbs
2025-03-06 23:00:20 +01:00
Jonas Jenwald
af89e77124
Merge pull request #19619 from Snuffleupagus/fix-#savedHasOwnCanvas
Fix the `#savedHasOwnCanvas` handling in the `StampAnnotation` class
2025-03-06 17:59:14 +01:00
calixteman
1abb7be11a
Merge pull request #19618 from calixteman/non_editable_stamp
[Editor] In edit mode, a non-editable stamp must be visible after the page is rendered
2025-03-06 16:23:55 +01:00
Jonas Jenwald
4f2cf38bfa
Merge pull request #19617 from Snuffleupagus/MathClamp
Introduce a helper function for clamping a value to a range
2025-03-06 15:48:14 +01:00
Jonas Jenwald
d646b2b270
Merge pull request #19610 from Snuffleupagus/rm-opacityToHex
[Editor] Remove the unused `opacityToHex` helper function (PR 19093 follow-up)
2025-03-06 15:42:38 +01:00
Calixte Denizet
f3454a738d [Editor] In edit mode, a non-editable stamp must be visible after the page is rendered 2025-03-06 15:37:27 +01:00
Jonas Jenwald
08fa4eba20 Fix the #savedHasOwnCanvas handling in the StampAnnotation class
This may not be possible to trigger in practice, however it seems that if `StampAnnotation.prototype.mustBeViewedWhenEditing` is called back-to-back with `isEditing === true` set then the second invocation could overwrite the `#savedHasOwnCanvas`-field and thus lose its initial state.
2025-03-06 15:17:52 +01:00
Jonas Jenwald
07bbbf75a5 Introduce a helper function for clamping a value to a range
Currently we have a number of spots in the code-base where we need to clamp a value to a [min, max] range. This is either implemented using `Math.min`/`Math.max` or with a local helper function, which leads to some unnecessary duplication.

Hence this patch adds and re-uses a single helper function for this, which we'll hopefully be able to remove in the future once https://github.com/tc39/proposal-math-clamp/ becomes generally available.
2025-03-06 14:05:26 +01:00
Jonas Jenwald
4ec5f08803 [Editor] Remove the unused opacityToHex helper function (PR 19093 follow-up)
The only call-site was removed in PR 19093, hence this is now dead code.
2025-03-05 23:10:56 +01:00
Jonas Jenwald
dea35aed4a
Merge pull request #19608 from Snuffleupagus/l10n-update
Update l10n files
2025-03-05 15:25:55 +01:00
Jonas Jenwald
c2fa55420c
Merge pull request #19607 from Snuffleupagus/ColorSpaceUtils-rm-singletons
Simplify the `ColorSpaceUtils.singletons` handling (PR 19564 follow-up)
2025-03-05 15:25:19 +01:00
Jonas Jenwald
de47041e77 Update l10n files
Given the recently added l10n-strings, let's do another update before the upcoming release to avoid needlessly "broken" translations.
2025-03-05 15:08:39 +01:00
Jonas Jenwald
d8d7235876 Simplify the ColorSpaceUtils.singletons handling (PR 19564 follow-up)
With the changes in PR 19564 the actual `ColorSpace`-classes where separated from the various static "helper" methods.
Hence it seems that we can now simplify/shorten this old code to instead cache the "standard" ColorSpaces directly on the `ColorSpaceUtils`-class.
2025-03-05 15:02:05 +01:00
Jonas Jenwald
fedfdf9d10
Merge pull request #19599 from Snuffleupagus/ColorSpace-rm-parseAsync
Remove `ColorSpaceUtils.parseAsync` and simplify the ColorSpace "API-surface"
2025-03-05 13:11:45 +01:00
Jonas Jenwald
fbf1f2ba15 Remove ColorSpaceUtils.parseAsync and simplify the ColorSpace "API-surface"
This patch reduces the number of `ColorSpaceUtils` static-methods, and in particular the `parseAsync` method is removed and it's now instead possible to have `parse` optionally return a Promise.
This thus removes the need to manually check if a `ColorSpace`-instance is cached, note the changes in the `src/core/evaluator.js` file.
2025-03-05 12:43:58 +01:00
calixteman
19bc5dcb0e
Merge pull request #19564 from calixteman/qcms_icc
[api-minor] Support using ICC profiles in using qcms (bug 860023)
2025-03-05 10:34:23 +01:00
Calixte Denizet
971be48b60 Support using ICC profiles in using qcms (bug 860023) 2025-03-05 10:29:59 +01:00
calixteman
4693b7ad2f
Merge pull request #19585 from calixteman/update_openjpeg2
Use the latest emsdk version to compile openjpeg decoder
2025-03-05 10:07:11 +01:00
Calixte Denizet
559ff28db3 Use the latest emsdk version to compile openjpeg decoder 2025-03-04 18:41:20 +01:00
Jonas Jenwald
ab8ebc9b77
Merge pull request #19604 from Snuffleupagus/bug-1943094
[api-minor] Limit the maximum canvas width/height, in addition to its total area (bug 1943094)
2025-03-04 17:53:31 +01:00
Jonas Jenwald
9f9de4508c [api-minor] Limit the maximum canvas width/height, in addition to its total area (bug 1943094)
Browsers not only limit the maximum total canvas area, but additionally also limit their maximum width/height which affects PDF documents with e.g. very tall and narrow pages.
To address this we add a new `maxCanvasDim` viewer-option, which in Firefox will use a browser preference, such that both the total canvas area and the width/height will affect when CSS-zooming is used.
2025-03-04 15:23:45 +01:00
Jonas Jenwald
5e6cfbe163
Merge pull request #19598 from Snuffleupagus/ColorSpace#subParse
Also cache "sub" ColorSpaces globally (PR 19583 follow-up)
2025-03-03 17:30:14 +01:00
Jonas Jenwald
ba640e5cdc Shorten various static ColorSpace method signatures
By passing around common parameters, i.e. everything that's not the ColorSpace-data, in an object we can shorten this code a little bit.
2025-03-03 11:08:05 +01:00
Jonas Jenwald
33dfc4dd5f Also cache "sub" ColorSpaces globally (PR 19583 follow-up)
Some ColorSpaces can reference other ColorSpaces, and since it's fairly common for many pages to use the same ColorSpaces (see e.g. `issue17061.pdf`) this can help reduce a lot of unnecessary re-parsing especially for e.g. `ICCBased` ColorSpaces.
2025-03-03 10:07:41 +01:00
Tim van der Meij
0c1ac54f48
Merge pull request #19597 from Snuffleupagus/then-arrow-functions
Use arrow functions with some `Promise.then` calls
2025-03-02 22:14:53 +01:00