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

6920 commits

Author SHA1 Message Date
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
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
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
Calixte Denizet
971be48b60 Support using ICC profiles in using qcms (bug 860023) 2025-03-05 10:29:59 +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
Jonas Jenwald
7b5cd9cddd Use arrow functions with some Promise.then calls
A lot of this is fairly old code, which we can shorten slightly by using arrow functions instead of "regular" functions.
2025-03-02 19:57:38 +01:00
Tim van der Meij
146bc58f32
Merge pull request #19596 from Snuffleupagus/Array-methods-arrow-functions
Use arrow function with various Array methods
2025-03-02 16:09:09 +01:00
Tim van der Meij
be6ef64a2c
Merge pull request #19577 from Snuffleupagus/isValidExplicitDest-reuse
Re-use the `isValidExplicitDest` helper function in the worker/viewer
2025-03-02 15:50:54 +01:00
Tim van der Meij
dfa6370161
Merge pull request #19589 from Snuffleupagus/RunLengthStream-fill
Replace a loop with `TypedArray.prototype.fill()` in the `RunLengthStream` class
2025-03-02 15:36:49 +01:00
Tim van der Meij
93759f34f4
Merge pull request #19571 from yjoer/master
Add the missing return type for `PDFWorker.fromPort()`
2025-03-02 15:27:10 +01:00
Jonas Jenwald
2e62f426fe Use arrow function with various Array methods
A lot of this is quite old code, which we can shorten slightly by using arrow functions instead of "regular" functions.
2025-03-02 15:19:04 +01:00
Jonas Jenwald
a3d259a681 Replace a loop with TypedArray.prototype.fill() in the RunLengthStream class
This is a tiny bit shorter, which cannot hurt.
2025-03-02 13:10:34 +01:00
Jonas Jenwald
4be79748c9 Add a GlobalColorSpaceCache to reduce unnecessary re-parsing
This complements the existing `LocalColorSpaceCache`, which is unique to each `getOperatorList`-invocation since it also caches by `Name`, which should help reduce unnecessary re-parsing especially for e.g. `ICCBased` ColorSpaces once we properly support those.
2025-03-01 14:21:05 +01:00
Jonas Jenwald
165d90fe26 Re-use the isValidExplicitDest helper function in the worker/viewer
Currently we re-implement the same helper function twice, which in hindsight seems like the wrong decision since that way it's quite easy for the implementations to accidentally diverge.
The reason for doing it this way was because the code in the worker-thread is able to check for `Ref`- and `Name`-instances directly, which obviously isn't possible in the viewer but can be solved by passing validation-functions to the helper.
2025-03-01 12:08:56 +01:00
Yeoh Joer
2221ccf160 Add the missing return type for PDFWorker.fromPort() 2025-02-28 02:49:44 +08:00
Jonas Jenwald
50c573d16d
Merge pull request #19563 from Snuffleupagus/loadType3Data-once
Invoke `TranslatedFont.prototype.loadType3Data` only *once* per font
2025-02-27 11:20:26 +01:00
Jonas Jenwald
56a683bc3b
Merge pull request #19562 from Snuffleupagus/issue-19550
Extend `getGlyphMapForStandardFonts` with some Cyrillic entries (issue 19550)
2025-02-27 11:17:42 +01:00
Jonas Jenwald
4e76a78341
Merge pull request #19549 from Snuffleupagus/fewer-EXPORT_DATA_PROPERTIES-2
[api-minor] Stop exporting, by default, a few additional Font properties (PR 11777 follow-up)
2025-02-27 11:15:27 +01:00
Jonas Jenwald
bdfa96878d Invoke TranslatedFont.prototype.loadType3Data only *once* per font
Currently we're first loading the font, and then for Type3 fonts we're invoking `loadType3Data` every time that the font is encountered.
That seems completely unnecessary, and it's probably connected to the age of this code, since the `loadType3Data`-method will only run once anyway (note the caching).
2025-02-26 15:17:11 +01:00
Jonas Jenwald
da17c7b82f
Merge pull request #19548 from Snuffleupagus/Font-exportData-disableFontFace-fontExtraProperties
Send `disableFontFace` and `fontExtraProperties` as part of the exported font-data
2025-02-26 11:25:29 +01:00
Jonas Jenwald
59cb9a064e Extend getGlyphMapForStandardFonts with some Cyrillic entries (issue 19550) 2025-02-26 10:16:06 +01:00
Jonas Jenwald
aa70b28365
Merge pull request #19555 from rossj/master
Pad rev 4 encryption keys to be >= 16 bytes (issue 19484)
2025-02-25 10:03:56 +01:00
Ross Johnson
4f25d7f6cd Fix decryption of R=4, V=4 files with < 16-byte keys by 0-padding - undocumented but matches Acrobat behavior (issue #19484) 2025-02-24 15:36:37 -06:00
Calixte Denizet
9e672ff05e [Editor] Add some telemetry for the signature editor (bug 1945827) 2025-02-24 21:10:04 +01:00
calixteman
fef706233d
Merge pull request #19551 from Snuffleupagus/loadSystemFont-fix-assert
Fix the `assert` in `FontLoader.prototype.loadSystemFont`
2025-02-24 16:49:03 +01:00
Jonas Jenwald
2966171a2b Fix the assert in FontLoader.prototype.loadSystemFont
Currently this `assert` isn't actually doing what it's supposed to, since the `FontLoader`-class doesn't have a `disableFontFace`-field.
The `FontFaceObject`-class on the other hand has such a field, hence we update the method-signature to be able to check the intended thing.
2025-02-24 16:09:07 +01:00
Jonas Jenwald
132ccf04db [api-minor] Stop exporting, by default, a few additional Font properties (PR 11777 follow-up)
None of the "composite", "subtype", or "type" properties are normally used on the main-thread and/or in the API, hence there's no need to include them in the exported font-data by default.
Given that these properties may still be useful when debugging, and that `debugger.mjs` actually relies on the "type" property, they will instead only be sent to the main-thread when the `fontExtraProperties` API-option is used.
2025-02-24 12:27:51 +01:00
Jonas Jenwald
d428db63c3 Improve the "FontFallback" handling on the worker-thread
Remove the `Catalog.prototype.fontFallback` method, and move its code into `PDFDocument.prototype.fontFallback` instead, to reduce the indirection a little bit.
Pass the `evaluatorOptions` directly to the `TranslatedFont.prototype.fallback` method, since nothing else in the `TranslatedFont`-class needs it now.
2025-02-24 09:34:58 +01:00
Jonas Jenwald
839e23f5c2 Send disableFontFace and fontExtraProperties as part of the exported font-data
These options are needed in the `FontFaceObject` class, and indirectly in `FontLoader` as well, which means that we currently need to pass them around manually in the API.
Given that the options are (obviously) available on the worker-thread, it's very easy to just provide them when creating `Font`-instances and then send them as part of the exported font-data. This way we're able to simplify the code (primarily on the main-thread), and note that `Font`-instances even had a `disableFontFace`-field already (but it wasn't properly initialized).
2025-02-24 09:34:48 +01:00
Calixte Denizet
cc3d6ab539 [Editor] Shift the signature editor when pasted
The idea is to avoid to have the pasted editor hidding the copied one:
the user could think that nothing happened.
So the top-left corner of the pasted one is moved to the bottom-right corner of the copied one.
2025-02-23 21:35:01 +01:00
Calixte Denizet
301f1bbf2b [Editor] Fix the position in the page of a drawing after it has been moved with the keyboard
When a drawing was moved with arrow keys and then printed or saved, the drawing wasn't moved finally.
So the fix is just about calling onTranslated once the translation is done.
2025-02-22 15:19:14 +01:00
Jonas Jenwald
637e95985a Simplify JpxImage.setOptions a little bit
After PR 19392 we're only invoking this method *once* per document, hence the early-return branch shouldn't be necessary any more.
2025-02-22 13:38:10 +01:00
Jonas Jenwald
641e2f506e [api-minor] Re-factor how the useWorkerFetch option is used internally
With the recently added OpenJPEG no-wasm fallback we need to send the `wasmUrl` option to the worker-thread *regardless* of the value of the `useWorkerFetch` option, since the fallback won't work if we don't have a URL to `import` it from.
For consistency the code is re-factored to always send the factory-urls to the worker-thread, and simply check the `useWorkerFetch` option there instead.

Also, as a follow-up to PR 19525, introduce a new `useWasm` option that can be used in e.g. browser-tests to forcibly disable WebAssembly usage.
2025-02-22 09:56:53 +01:00
Jonas Jenwald
6d3bb47655
Merge pull request #19525 from calixteman/bug1935076_part2
Provide a js fallback when the wasm version of openjpeg is failing to load (bug 1935076)
2025-02-22 09:34:40 +01:00
calixteman
c2e616dfc9
Merge pull request #19534 from calixteman/signature_description_test
[Editor] Add a test for copy & paste a signature editor
2025-02-21 23:01:31 +01:00
Jonas Jenwald
553ec7babc
Merge pull request #19128 from nicolo-ribaudo/draw-page-portion
[api-minor] Render high-res partial page views when falling back to CSS zoom (bug 1492303)
2025-02-21 22:24:41 +01:00
Calixte Denizet
814d2bbe6d [Editor] Add a test for copy & paste a signature editor
This patch fixes an issue when pasting: an exception was thrown when pasting.
And while writing the test and comparing the paths in the svg, I found a difference
which is fixed thanks to call to the right constructor (to take into account the inheritance)
in inkdraw.js
2025-02-21 21:43:19 +01:00
Xiphoseer
24aa39eb14 Consider textRise when showing type3 font glyphs
Add test case for issue 19532
2025-02-21 21:31:04 +01:00
Calixte Denizet
36e4f5c222 Provide a js fallback when the wasm version of openjpeg is failing to load (bug 1935076) 2025-02-21 19:03:47 +01:00
Nicolò Ribaudo
458b2ee402
[api-minor] Render high-res partial page views when falling back to CSS zoom (bug 1492303)
When rendering big PDF pages at high zoom levels, we currently fall back
to CSS zoom to avoid rendering canvases with too many pixels. This
causes zoomed in PDF to look blurry, and the text to be potentially
unreadable.

This commit adds support for rendering _part_ of a page (called
`PDFPageDetailView` in the code), so that we can render portion of a
page in a smaller canvas without hiting the maximun canvas size limit.

Specifically, we render an area of that page that is slightly larger
than the area that is visible on the screen (100% larger in each
direction, unless we have to limit it due to the maximum canvas size).
As the user scrolls around the page, we re-render a new area centered
around what is currently visible.
2025-02-21 10:00:55 -08:00
Jonas Jenwald
e3ea92603d
Merge pull request #19493 from Snuffleupagus/URL-parse
Introduce some `URL.parse()` usage in the code-base
2025-02-21 10:40:32 +01:00
Jonas Jenwald
d5ce35f744 Move the EXIF-block replacement into JpegStream (PR 19356 follow-up)
Currently we modify the EXIF-block in place, which may end up "breaking" the JPEG-data of the original PDF document since e.g. saving it from the viewer no longer contains the real EXIF-block.
Hence the EXIF-block replacement is moved into the `JpegStream` class, such that we can copy the data before doing the replacement.
2025-02-20 12:41:39 +01:00
Jonas Jenwald
db7cf40a30 Don't cache free/missing XRef entries (issue 19510)
During the XRef stream parsing we're attempting to lookup an entry that hasn't yet been found, since parsing is currently running, and given that we'd also cache free/missing XRef entries we'd then return an incorrect value during normal PDF parsing.

The simplest solution here is to just not cache free/missing XRef entries, since a properly generated PDF document shouldn't be trying to access objects it doesn't contain.
Furthermore, the amount of "extra" parsing now needed for such XRef entries shouldn't be significant enough to be an issue.
2025-02-18 18:04:00 +01:00
Jonas Jenwald
426c730e11
Merge pull request #19504 from Snuffleupagus/eslint-fix-arrow-body-style
Fix all outstanding ESLint `arrow-body-style` warnings
2025-02-18 17:52:36 +01:00
Calixte Denizet
9984afe6a6 [Editor] Wait for switching to stamp mode before adding a new editor when dnd'ing an image
When dnd'ing an image with the FreeText mode enabled, the image wasn't correctly added.
2025-02-18 10:53:34 +01:00
calixteman
203452c170
Merge pull request #19508 from calixteman/issue19505
[JS] Skip throwing actions
2025-02-17 22:57:14 +01:00
Calixte Denizet
8f9232202f [JS] Skip throwing actions
It fixes #19505.

We were invaliding throwing actions (in setting event.rc to false) and all the event process was stopped.
Now we're just dumping the exception in the console: the action is skipped and event.rc is not set
else the input fields aren't updated wit KeyStroke actions.
2025-02-17 21:58:20 +01:00
Calixte Denizet
3fc6b1321f [Editor] Scale the signature editor when it's too large (bug 1948741) 2025-02-17 20:20:26 +01:00
Jonas Jenwald
36979e9eb2 Fix all outstanding ESLint arrow-body-style warnings
Currently this rule is disabled in a number of spots across the code-base, and unless absolutely necessary we probably shouldn't disable linting, so let's just update the code to fix all the outstanding cases.
2025-02-17 15:45:44 +01:00