Commit Graph

17158 Commits

Author SHA1 Message Date
Tim van der Meij
33f5d94f23
Merge pull request #16172 from Snuffleupagus/margin-inline
Use `margin-inline` in the `web/pdf_viewer.css` file (PR 14670 follow-up)
2023-03-19 12:43:44 +01:00
Tim van der Meij
6b89e66bd0
Merge pull request #16169 from Snuffleupagus/viewer-html-preprocessor-cleanup
Clean-up the pre-processor statements in `web/viewer.html`
2023-03-19 12:34:11 +01:00
Jonas Jenwald
1efe41c248 Use margin-inline in the web/pdf_viewer.css file (PR 14670 follow-up)
Given that the viewer always set the `dir`-attribute, we should be able to use logical margins in this CSS file as well; please also see https://developer.mozilla.org/en-US/docs/Web/CSS/margin-inline
2023-03-19 12:31:34 +01:00
Tim van der Meij
27fe7e9e72
Merge pull request #16171 from Snuffleupagus/PDFViewer-cleanup-scale-methods
Clean-up the `PDFViewer.{increaseScale, decreaseScale}` methods
2023-03-19 12:30:11 +01:00
Jonas Jenwald
9060757064 Clean-up the PDFViewer.{increaseScale, decreaseScale} methods
The signatures of these methods were changed in PR 15886, which has now been included in a couple of releases, hence it should hopefully be OK to remove the fallback code-paths now.
Also, the methods are updated slightly to be explicit about what options are supported and we'll no longer pass along any arbitrary options to the "private" methods.
2023-03-19 11:47:02 +01:00
Jonas Jenwald
7d688769cf Clean-up the pre-processor statements in web/viewer.html
Some of these pre-processor statements are *many* years old, and could thus do with some clean-up. Note that the pre-processor originally didn't support else-if statements, and by using those the code becomes a bit less verbose.
2023-03-18 17:17:46 +01:00
Tim van der Meij
9db4509664
Merge pull request #16166 from Snuffleupagus/pr-16151-followup
Simplify the `applyTransferMapsToCanvas` method (PR 16151 follow-up)
2023-03-18 14:06:42 +01:00
Calixte Denizet
da080cc26e [api-minor] Use a SVG filter when rendering pages in HCM
The idea is to apply an overall filter on each page: the main advantage
is to have some filtered images which could help to make them visible for
some users.
2023-03-18 12:45:10 +01:00
Jonas Jenwald
2fea9ee21b Simplify the applyTransferMapsToCanvas method (PR 16151 follow-up)
During review of PR 16151 this method was simplified, however I overlooked the fact that we now can (and really should) improve this by removing duplication.
2023-03-17 12:58:35 +01:00
Jonas Jenwald
85166c60fd
Merge pull request #16162 from Snuffleupagus/issue-16139
Warn about missing/incorrect `--scale-factor` CSS-variable in `renderTextLayer` (issue 16139)
2023-03-16 16:41:13 +01:00
Jonas Jenwald
0e54a3c37a Warn about missing/incorrect --scale-factor CSS-variable in renderTextLayer (issue 16139)
Unfortunately I don't believe that we can simply add a default `--scale-factor` CSS-variable to the `container`-element, since that might not be entirely appropriate/correct in all cases.[1]
However, we can at least print a console-error to hopefully make this situation more apparent to users. (This is purposely not using the `warn` helper-function, since those messages can be disabled.)

---
[1] One example is in our reference-tests, where we don't need to add it to the `container`-element itself.
2023-03-16 11:53:12 +01:00
Jonas Jenwald
5e4b3d13eb
Merge pull request #16151 from Snuffleupagus/DefaultFilterFactory
[api-minor] Extend general transfer function support to browsers without `OffscreenCanvas`
2023-03-14 14:03:26 +01:00
Jonas Jenwald
07a3283e53
Merge pull request #16152 from Snuffleupagus/type-fixes
Miscellaneous small TypeScript fixes
2023-03-14 13:24:51 +01:00
Jonas Jenwald
50c844c5b8 Stop including isOffscreenCanvasSupported in the "StartRenderPage" message
With the previous commit this is now completely unused in API, hence it can be removed. This is done in a separate commit to make it easier to re-instate it, would the need ever arise.
2023-03-14 13:09:20 +01:00
Jonas Jenwald
fc055dbd80 [api-minor] Extend general transfer function support to browsers without OffscreenCanvas
This patch extends PR 16115 to work in all browsers, regardless of their `OffscreenCanvas` support, such that transfer functions will be applied to general rendering (and not just image data).
In order to do this we introduce the `BaseFilterFactory` that is then extended in browsers/Node.js environments, similar to all the other factories used in the API, such that we always have the necessary factory available in `src/display/canvas.js`.

These changes help simplify the existing `putBinaryImageData` function, and the new method can easily be stubbed-out in the Firefox PDF Viewer.

*Please note:* This patch removes the old *partial* transfer function support, which only applied to image data, from Node.js environments since the `node-canvas` package currently doesn't support filters. However, this should hopefully be fine given that:
 - Transfer functions are not very commonly used in PDF documents.
 - Browsers in general, and Firefox in particular, are the *primary* development target for the PDF.js library.
 - The FAQ only lists Node.js as *mostly* supported, see https://github.com/mozilla/pdf.js/wiki/Frequently-Asked-Questions#faq-support
2023-03-14 13:09:08 +01:00
calixteman
945855a2b8
Merge pull request #16153 from calixteman/rm_base
Remove <base> tag from the Firefox built-in viewer (bug 1821408)
2023-03-14 10:40:15 +01:00
Calixte Denizet
ea1d090109 Remove <base> tag from the Firefox built-in viewer (bug 1821408)
The tag <base> is used to resolve relative URIs within the document.
Newly added SVG filters use a relative URI which then use the URI in base
but this one mismatches with the document URI and consequently filters are
not found in the Firefox viewer.
So this patch just removes <base> and replace few relative URLs by absolute
ones.
2023-03-14 10:12:42 +01:00
Jonas Jenwald
103fda1d91 Update the canvasContext parameter, in RenderParameters (issue 16133)
Hopefully this works correctly (since I don't know anything about TypeScript), given that `CanvasRenderingContext2D` is a standard name; please see https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D
2023-03-13 16:56:36 +01:00
Jonas Jenwald
e981badb94 Mark updateMatchesCountOnProgress, in the PDFFindControllerOptions, as optional (issue 15990) 2023-03-13 16:46:33 +01:00
Tim van der Meij
351d11c9bd
Merge pull request #16147 from Snuffleupagus/update-packages
Update packages and translations
2023-03-12 13:29:51 +01:00
Jonas Jenwald
c6c9eb4ccb Update l10n files 2023-03-12 10:40:53 +01:00
Jonas Jenwald
1d06523366 Update npm packages 2023-03-12 10:36:00 +01:00
Tim van der Meij
9819f1cc6b
Merge pull request #16108 from Snuffleupagus/delay-cleanup
Slightly delay cleanup, after rendering, in documents with large images
2023-03-11 15:52:12 +01:00
Tim van der Meij
05f29c8720
Merge pull request #16141 from Snuffleupagus/FilterFactory-docId
Include the document-id in the SVG-filter names (PR 16062 follow-up)
2023-03-11 15:45:42 +01:00
Tim van der Meij
1234d207e9
Merge pull request #16142 from Snuffleupagus/issue-16134
Fix the JSDoc `returns`-type for two `PageViewport`-methods (issue 16134)
2023-03-11 14:53:21 +01:00
Tim van der Meij
cc499505df
Merge pull request #16123 from Snuffleupagus/Node-16
[api-minor] Update the minimum supported Node.js version to 16
2023-03-11 14:49:59 +01:00
calixteman
b2a86350fc
Merge pull request #16096 from bungeman/fix_trig_functions
Correct PostScript trigonometric operators
2023-03-11 14:32:23 +01:00
calixteman
4a4c5d0fe2
Merge pull request #16145 from calixteman/issue16135
Move the svg definitions in its own div
2023-03-10 17:45:29 +01:00
Calixte Denizet
f9539e57ef Move the svg definitions in its own div
This way the svg element doesn't take up space in the viewer.
Fixes issue #16135.
2023-03-10 17:03:40 +01:00
calixteman
0338df2f6d
Merge pull request #16138 from calixteman/bug1820909
Fix search in pdf a containing some UTF-32 characters (bug 1820909)
2023-03-09 19:15:49 +01:00
Jonas Jenwald
9232264b8a Fix the JSDoc returns-type for two PageViewport-methods (issue 16134)
The affected methods have always returned Arrays, however the JSDoc did not accurately reflect that.
2023-03-09 15:57:16 +01:00
Jonas Jenwald
92296fa6a1 Include the document-id in the SVG-filter names (PR 16062 follow-up)
In the general PDF.js library multiple PDF documents may be opened on the same web-page, which is why we many years ago started using document-specific identifiers to prevent issues with global data such e.g. with fonts.
Hence we need to treat the identifiers generated by the `FilterFactory` in the same way, since the SVG-filters for two separate PDF documents may otherwise get identical ids.
2023-03-09 15:35:29 +01:00
Calixte Denizet
07b094729e Fix search in pdf a containing some UTF-32 characters (bug 1820909)
Some chars were supposed to have a length equals to 1 but UTF-32 chars
can be longuer.
2023-03-09 15:03:01 +01:00
Jonas Jenwald
c0671ac133 Slightly increase the maximum image sizes that we'll cache
The current value originated in PR 2317, and in the decade that have passed the amount of RAM available in (most) devices should have increased a fair bit.
Nowadays we also do a much better job of detecting repeated images at both the page- and document-level, which helps reduce overall memory-usage in many documents.

Finally the constant is also moved into the `src/shared/util.js` file, since it was implicitly used on both the main- and worker-thread previously.
2023-03-08 17:06:10 +01:00
Jonas Jenwald
15d9faba57 Slightly delay cleanup, after rendering, in documents with large images
Currently in PDF documents with large images we immediately cleanup once rendering has finished, in order to reduce memory-usage.
Normally that shouldn't be a big problem, however when e.g. repeated zooming happens in the viewer that could easily lead to a lot of wasted resources (and waiting).

Hence this patch, which introduces a new `PDFPageProxy` method that will slightly delay cleanup after rendering.
2023-03-08 17:06:09 +01:00
Jonas Jenwald
e7a7f02f4c Convert a couple of fields/methods into properly private ones in PDFPageProxy
These were always intended to be *private*, so let's use modern JS features to actually enforce that.
2023-03-08 17:06:09 +01:00
calixteman
a0ef5a4ae1
Merge pull request #16115 from calixteman/issue16114
Apply transfer filters to any graphic commands
2023-03-08 14:53:41 +01:00
calixteman
32e2f7c8e5
Merge pull request #16131 from calixteman/issue16049
Partially revert PR 15578
2023-03-08 12:57:18 +01:00
Jonas Jenwald
6839f15a32
Merge pull request #16128 from Snuffleupagus/issue-16127
Support (rare) Type3 fonts with Pattern resources (issue 16127)
2023-03-08 12:21:53 +01:00
Jonas Jenwald
e5427ab11b
Merge pull request #16122 from Snuffleupagus/rm-onUnsupportedFeature
[api-minor] Remove the deprecated `onUnsupportedFeature` functionality (PR 15758 follow-up)
2023-03-08 12:16:27 +01:00
Calixte Denizet
dabfbc623e Partially revert PR 15578
The dimensions still need to be fixed (from times to times they're in px)
but it doesn't have to be postponed anymore.
To test it: draw something and when resizing look at the dimensions of the div
in devtools, the units must be %.
2023-03-08 12:10:27 +01:00
calixteman
cc555a389b
Merge pull request #16117 from calixteman/workaround_bug1820511
Avoid to have a factor too close to 2 when downscaling image
2023-03-08 11:12:56 +01:00
Calixte Denizet
1617ee6c3f Avoid to have a factor too close to 2 when downscaling image
It's a workaround for bug 1820511: it only affects Firefox on Windows
using the D2D backend.
2023-03-08 11:05:46 +01:00
calixteman
39ff039b8a
Merge pull request #16125 from calixteman/firefox_max_area
[api-minor] Add an option to set the max canvas area
2023-03-08 10:56:03 +01:00
Calixte Denizet
e9474f1c84 [api-minor] Add an option to set the max canvas area 2023-03-08 10:37:06 +01:00
Jonas Jenwald
471aef5fc6 Support (rare) Type3 fonts with Pattern resources (issue 16127)
This simply extends the approach in PR 10727 to also cover Patterns, which shouldn't be a common occurrence in Type3 fonts (since this is the first issue we've seen).
2023-03-08 09:20:52 +01:00
Calixte Denizet
8304df2520 Apply transfer filters to any graphic commands 2023-03-07 22:17:19 +01:00
calixteman
e0d934ac9d
Merge pull request #16124 from calixteman/issue16119
Slightly modify the max width of a tracking space
2023-03-07 22:12:02 +01:00
Calixte Denizet
b8dda089e2 Slightly modify the max width of a tracking space 2023-03-07 19:38:49 +01:00
Jonas Jenwald
6d3506548d [api-minor] Update the minimum supported Node.js version to 16
This patch updates the minimum supported environments as follows:
 - Node.js 16, which was released on 2021-04-20; see https://en.wikipedia.org/wiki/Node.js#Releases

Note also that Node.js 14 will very soon reach EOL, and thus no longer receive any security updates.
2023-03-07 16:33:56 +01:00