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

19217 commits

Author SHA1 Message Date
Tim van der Meij
fcea7e7b4b
Bump the stable version in pdfjs.config 2024-05-28 18:44:56 +02:00
Jonas Jenwald
0cec644372
Merge pull request #18179 from nicolo-ribaudo/zooming-utilities
[api-minor] Simplify API to implement zoom in custom viewers
2024-05-28 16:39:06 +02:00
Tim van der Meij
027ada81a7
Merge pull request #18170 from Snuffleupagus/TextLayerBuilder-rm-setTextContentSource
[api-minor] Remove the `setTextContentSource` method in `TextLayerBuilder` (PR 18104 follow-up)
2024-05-28 16:38:52 +02:00
Nicolò Ribaudo
b7933d8750
Add origin parameter to updateScale
This parameter allows defining which point should remain
fixed while scaling the document. It can be used, for example,
to implement "zoom around the cursor" or "zoom around
pinch center".

The logic was previously implemented in `web/app.js`, but
moving it to the viewer scaling utilities themselves makes it
easier to implement similar zooming functionalities in
other embedders.
2024-05-28 16:19:47 +02:00
Tim van der Meij
ee545930ea
Merge pull request #18171 from Snuffleupagus/move-pendingTextLayers
Don't register a pending `TextLayer` until `render` is invoked (PR 18104 follow-up)
2024-05-28 15:37:51 +02:00
Nicolò Ribaudo
161c7045f6
Unify increaseScale/decreaseScale logic as updateScale
`updateScale` receives a `drawingDelay`, a `scaleFactor` and/or a number of `steps`.
If `scaleFactor` is a positive number different from `1` the current scale is multiplied by
that number. Otherwise, if `steps` if a positive integer the current scale is multiplied by
`DEFAULT_SCALE_DELTA` `steps` times. Finally, if `steps` is a negative integer, the
current scale is divided by `DEFAULT_SCALE_DELTA` `abs(steps)` times.
2024-05-28 14:02:39 +02:00
Tim van der Meij
aac738c805
Merge pull request #18169 from Snuffleupagus/worker-shorter-code
Slightly shorten some worker-thread code
2024-05-28 13:36:05 +02:00
Tim van der Meij
401a1d4a34
Merge pull request #18161 from Snuffleupagus/types-ES2022
Target ES2022 when building the TypeScript definitions (issue 17932)
2024-05-28 13:28:22 +02:00
calixteman
95a7de9f98
Merge pull request #18174 from calixteman/make_dialog_css
Move the dialog css stuff in its own file
2024-05-28 11:26:49 +02:00
Calixte Denizet
697255d7cc Move the dialog css stuff in its own file
In order to share common parts between different dialogs, this patch
aims to slightly refactor the css in making it more generic.
This way it'll simplify adding a new dialog (we want to add a new one when
leaving an unsaved document).
2024-05-27 22:25:18 +02:00
calixteman
4bdc75f18d
Merge pull request #18165 from calixteman/integrationtest_switch_foo
Simplify the integration test in adding a function to turn on/off an editing tool
2024-05-27 12:00:25 +02:00
Calixte Denizet
b6b02ccff6 Simplify the integration test in adding a function to turn on/off an editing tool 2024-05-27 11:33:52 +02:00
Jonas Jenwald
f2e7eee00e Don't register a pending TextLayer until render is invoked (PR 18104 follow-up)
After the re-factoring in PR 18104 there's now a *theoretical* risk that a pending `TextLayer` is never removed, which we can avoid by not registering it until `render` is invoked.
Note that this doesn't affect the viewer or tests, but if a third-party user calls `new TextLayer(...)` without a following call of either the `render`- or `cancel`-method we'd block global clean-up without this patch.
2024-05-26 18:38:40 +02:00
Jonas Jenwald
303e793264 Introduce a helper method, in PDFPageView, for dispatching "...layerrendered" events
Currently we repeat virtually the same, with the exception of the name, event dispatching code four times for the different viewer layers.
2024-05-26 12:44:06 +02:00
Jonas Jenwald
db86f8132e [api-minor] Remove the setTextContentSource method in TextLayerBuilder (PR 18104 follow-up)
The `setTextContentSource` functionality is very old code, and was introduced years ago together with streaming of textContent.
By moving the `streamTextContent`-call into the `TextLayerBuilder` class we collect more functionality in one place and slightly reduce the amount of code needed.
2024-05-26 12:43:59 +02:00
Jonas Jenwald
27436d52b2 Reduce indentation when parsing new annotations in getOperatorList
This code has, over the years, become more complex and less indentation generally helps readability.
2024-05-25 12:00:44 +02:00
Jonas Jenwald
ce52ce063e Change parsingType3Font to a getter (PR 14448 follow-up)
We can easily "compute" `parsingType3Font` from the `type3FontRefs`-value, and thus avoid having to separately track two related properties.
2024-05-25 10:46:12 +02:00
Jonas Jenwald
c349ac3a5d Skip the temporary variable when calling #findStreamLength (PR 18125 follow-up) 2024-05-25 10:38:32 +02:00
Jonas Jenwald
17e09e5478
Merge pull request #18159 from Snuffleupagus/loadingParams-test
Improve the `loadingParams` functionality in the API
2024-05-24 23:21:24 +02:00
Jonas Jenwald
6460e9ebcf
Merge pull request #18160 from Snuffleupagus/file-layout-overview
Update the "File Layout Overview" docs
2024-05-24 22:31:30 +02:00
Jonas Jenwald
b78480a375
Merge pull request #18166 from Snuffleupagus/bug-1898802
Prevent XRef errors from breaking font loading (bug 1898802)
2024-05-24 22:29:21 +02:00
Jonas Jenwald
cfcb700ecc Prevent XRef errors from breaking font loading (bug 1898802)
Note that the referenced file is trivially corrupt, since it contains *two* PDF documents placed in the same file which doesn't make sense (and isn't how a PDF document should be updated).
However it's still a good idea to ensure that `loadFont` is able to handle errors when resolving References, since that allows us to invoke the existing fallback font handling.
2024-05-24 21:37:35 +02:00
Jonas Jenwald
78deb798e3 Target ES2022 when building the TypeScript definitions (issue 17932)
This should avoid the latest JS features appearing in the TypeScript definitions, and given the currently supported browsers/environments (in PDF.js) we shouldn't need to target an even older ES-version.
2024-05-24 12:14:58 +02:00
Jonas Jenwald
03601f99d8 Update the "File Layout Overview" docs
Apparently we forgot to update this in the version 4 release, so better late than never I suppose.
 - Use `.mjs` extensions where appropriate.
 - Remove mention of the `debugger`-functionality, since that's not really relevant to users.
 - Unify the whitespace handling to use spaces consistently.
2024-05-24 11:42:06 +02:00
calixteman
18a7bd60f7
Merge pull request #18156 from calixteman/bug1882613
[GeckoView] Don't use the system fonts (bug 1882613)
2024-05-24 09:56:38 +02:00
Calixte Denizet
adb2bb5af8 [GeckoView] Don't use the system fonts (bug 1882613)
On Android there's almost no chance we find a substitution font so
just use one of the font embedded in pdf.js.
2024-05-24 09:30:22 +02:00
Jonas Jenwald
06334c97ef Improve the loadingParams functionality in the API
- Move the definition of the `loadingParams` Object, to simplify the code.

 - Add a unit-test, since none existed and the viewer depends on this functionality.
2024-05-24 09:26:40 +02:00
Tim van der Meij
08bf96865d
Merge pull request #18154 from timvandermeij/integration-test-rect
Introduce a `getRect` utility function for the integration tests
2024-05-23 19:27:52 +02:00
Tim van der Meij
145d66090f
Introduce a getRect utility function for the integration tests
Over time the number of integration tests that get the rectangle for a
given selector has increased quite a bit, and the code to do so has
consequently become duplicated.

This commit refactors the integration tests to move the rectangle
fetching code to a single place, which reduces the code by over 400
lines and makes the individual tests simpler.
2024-05-23 18:40:03 +02:00
Tim van der Meij
0c562f0a98
Merge pull request #18153 from timvandermeij/updates
Update dependencies and translations to the most recent versions
2024-05-23 17:35:03 +02:00
Tim van der Meij
af5d7908fe
Update translations to the most recent versions 2024-05-23 16:02:20 +02:00
Tim van der Meij
e40e95faf4
Update dependencies to the most recent versions 2024-05-23 16:02:18 +02:00
Tim van der Meij
1c3195b86f
Merge pull request #18152 from Snuffleupagus/TextLayerBuilder-shorter
Shorten the code in the `web/text_layer_builder.js` file
2024-05-23 14:48:00 +02:00
Jonas Jenwald
cb388c6658 Shorten the code in the web/text_layer_builder.js file
- Use `this` rather than explicitly spelling out the class-name in the static `#enableGlobalSelectionListener` method, since that leads to shorter code. Given that all the relevant static fields are *private* ESLint will catch any scope errors in the code.

 - Reduce a little bit of duplication when using the `#selectionChangeAbortController` signal.

 - Utilize early returns in the "selectionchange" event handler, since that reduces overall indentation which helps readability a tiny bit.
2024-05-23 13:53:51 +02:00
Tim van der Meij
b7b8e5ef78
Merge pull request #18145 from timvandermeij/merge-stream
Remove the `merge-stream` dependency in favor of the `ordered-read-streams` dependency
2024-05-22 16:48:42 +02:00
Tim van der Meij
723e5b2779
Remove the merge-stream dependency in favor of the ordered-read-streams dependency
The `merge-stream` dependency is no longer maintained and doesn't work
in combination with Gulp 5 anymore (for more information refer to
https://github.com/gulpjs/gulp/issues/2802#issuecomment-2094130656).

Fortunately the Gulp team maintains a drop-in replacement dependency
called `ordered-read-streams` with the same API as `merge-stream`.
Indeed, running all affected Gulp targets and comparing build artifacts
with `diff -r <old> <new>` confirms that no unexpected changes are made.

Fixes a part of #17922.
2024-05-22 15:14:36 +02:00
Tim van der Meij
821f3a1ef3
Merge pull request #18143 from Snuffleupagus/issue-18138
Improve /Page validation for linearized documents (issue 18138)
2024-05-22 13:27:49 +02:00
Jonas Jenwald
3afa9bfc42 Improve /Page validation for linearized documents (issue 18138)
The referenced PDF document contains corrupt linearization-data, that doesn't point to the *first* page as intended.
2024-05-22 12:04:02 +02:00
Jonas Jenwald
2a52fda11b
Merge pull request #17770 from Aditi-1400/fix-issue-16843
Add language attribute to canvas
2024-05-21 21:35:43 +02:00
Tim van der Meij
14942271d1
Merge pull request #17974 from timvandermeij/integration-tests-timeout-scripting
Remove most `waitForTimeout` usage from the scripting integration tests
2024-05-21 20:53:51 +02:00
Tim van der Meij
23de3fd549
Remove most waitForTimeout usage from the scripting integration tests
This commit replaces most `waitForTimeout` occurrences with calls to
`waitForFunction` or `waitForSandboxTrip`. Note that the occurrences in
the "must check that focus/blur callbacks aren't called" test remain
until we find a good way to ensure that nothing happened after the tab
switches (because currently we can't be sure that nothing happens since
there is nothing to await).
2024-05-21 18:36:05 +02:00
Tim van der Meij
2ad4601d04
Merge pull request #18129 from nicolo-ribaudo/test-css-only-zoom
Add test for drawing delay with CSS-only zoom
2024-05-21 18:35:05 +02:00
calixteman
5da2894278
Merge pull request #18136 from calixteman/ml_stamp
[Editor] Pass a buffer instead of a blob url to the ML api
2024-05-21 18:24:26 +02:00
calixteman
6860288df2
Merge pull request #17968 from calixteman/freetext_update_popup
[Editor] Update popup position and contents after a FreeText has been edited
2024-05-21 17:59:39 +02:00
Nicolò Ribaudo
53d866660a
Add test for drawing delay with CSS-only zoom
This commit adds a test for 0603d1ac18.
Before the fix the `pagerendered` events would be fired just 2-3
milliseconds after the call to `increaseScale`/`decreaseScale`.
2024-05-21 17:17:48 +02:00
Calixte Denizet
b20ddff300 [Editor] Pass a buffer instead of a blob url to the ML api 2024-05-21 17:07:03 +02:00
Calixte Denizet
2369e40d2e [Editor] Update popup position and contents after a FreeText has been edited 2024-05-21 16:54:10 +02:00
Aditi
9edca0a5ed Add lang attribute to canvas element
Fixes issue #16843.
In certain cases, the text layer was misaligned
due to a difference between the `lang` attribute
of the viewer and the canvas. This commit addresses
the problem by adding the `lang` attribute to the canvas.

The issue was caused because PDF.js uses serif/sans-serif
fonts to generate the text layer and relies on system fonts.
The difference in the `lang` attribute led to different fonts
being picked, causing the misalignment.
2024-05-21 19:41:24 +05:30
Jonas Jenwald
dce9c6d956
Merge pull request #18125 from Snuffleupagus/issue-18122
Support corrupt PDF documents that contain "endsteam" commands (issue 18122)
2024-05-21 16:09:01 +02:00
Tim van der Meij
661a62bb30
Merge pull request #18121 from calixteman/update_puppeteer_22_9_0
Update puppeteer to 22.9.0
2024-05-21 14:29:29 +02:00