Commit Graph

12942 Commits

Author SHA1 Message Date
utopianknight
c0b671d91b Photon Design 2020-08-19 14:21:13 +04:00
IanJiang0817
dee0c29f6f fix webpack config problem caused by breaking changes of worker-loader 2020-08-19 17:02:16 +08:00
Tim van der Meij
b52b36f6a5
Merge pull request #12230 from timvandermeij/reference-test-print
Implement reference testing for printing
2020-08-18 13:11:18 +02:00
Tim van der Meij
483efedc66
Include reference tests for text/choice/button widget printing 2020-08-18 12:36:33 +02:00
Tim van der Meij
8ccf09d5dd
Implement reference testing for printing
This commit includes support for rendering pages in printing mode,
which, when combined with annotation storage data, is useful for testing
if form data is correctly rendered onto the printed canvas.
2020-08-18 12:36:33 +02:00
Tim van der Meij
37e9c97cec
Merge pull request #12229 from brendandahl/ann-event
Dispatch event when annotations have finished rendering.
2020-08-17 23:43:04 +02:00
Brendan Dahl
7bba4931ad Dispatch event when annotations have finished rendering.
This is needed for some smoke tests in mozilla central for testing forms
in pdf.js.

Note: AnnotationLayerBuilder.render() doesn't really need to be async, but
we're talking of making the annotation's render functions async, so this
will make that switch easier.
2020-08-17 14:29:24 -07:00
Tim van der Meij
ebb903e506
Merge pull request #12227 from Snuffleupagus/dist-more-es5
Include `image_decoders-es5`/`minified-es5` in the `pdfjs-dist` library (issue 12220)
2020-08-17 19:30:26 +02:00
Jonas Jenwald
e079c180c3 Include minified-es5 in the pdfjs-dist library (issue 12220)
Note that this will increase the run-time of `gulp dist` and `gulp dist-install`, but that's unavoidable given that there's now additional building happening.
2020-08-17 15:18:14 +02:00
Jonas Jenwald
1cf660ba73 Add a image_decoders-es5 gulp task, and include it in the pdfjs-dist library 2020-08-17 14:59:50 +02:00
Tim van der Meij
628a1ee04e
Merge pull request #12219 from Snuffleupagus/handleTransferFunction
Add (basic) support for transfer functions to Images (issue 6931, bug 1149713)
2020-08-17 13:26:19 +02:00
Jonas Jenwald
1058f16605 Add (basic) support for transfer functions to Images (issue 6931, bug 1149713)
This is *similar* to the existing transfer function support for SMasks, but extended to simple image data.
Please note that the extra amount of data now being sent to the worker-thread, for affected /ExtGState entries, is limited to *at most* 4 `Uint8Array`s each with a length of 256 elements.

Refer to https://www.adobe.com/content/dam/acom/en/devnet/acrobat/pdfs/PDF32000_2008.pdf#G9.1658137 for additional details.
2020-08-17 10:34:12 +02:00
Jonas Jenwald
9d3e046a4f Don't cache /ExtGState entries that contain fonts (PR 12087 follow-up)
I completely overlooked the fact that `PartialEvaluator.handleSetFont` also updates the current `state`, which means that currently we're not actually handling font data correctly for cached /ExtGState data. (Thankfully, using /ExtGState to set a font is somewhat rare in practice.)
2020-08-17 08:17:25 +02:00
Tim van der Meij
192afb87e3
Merge pull request #12203 from staktrace/zoomfix
Bug 1392361 - Fix zooming sensitivity on macOS
2020-08-16 22:36:37 +02:00
Tim van der Meij
9be177d2de
Merge pull request #12210 from Snuffleupagus/minified-keep-names
Keep the original class/function names when minifying code (issue 12209)
2020-08-16 22:19:30 +02:00
Tim van der Meij
66bbe82cc5
Merge pull request #12212 from staktrace/touchfix
Bug 1643508 - Disable touch-based pinch zooming on pdf.js.
2020-08-16 22:12:02 +02:00
Brendan Dahl
67c361b2f4
Merge pull request #12211 from Snuffleupagus/_saveInProgress-reset
Wait until saving has finished before resetting `PDFViewerApplication._saveInProgress` (PR 12137 follow-up)
2020-08-13 08:38:47 -07:00
Kartikaya Gupta
c6e5686b6a Bug 1643508 - Disable touch-based pinch zooming on pdf.js.
Currently using a touchscreen with pdf.js doesn't work so well. In Firefox,
with apz.allow_zooming = false (default on current release/beta), it does a
reflow zoom which makes the UI elements bigger. And with apz.allow_zooming = true
(default on current Firefox nightly), or in Chrome, it does a smooth pinch-zoom
but that also scales up the entire UI. Neither of these is a particularly good
experience, so this patch just disables any multi-touch gestures. Touch-based
panning (which involves a single touch point) is left unaffected.
2020-08-13 09:22:30 -04:00
Jonas Jenwald
b26d736809 Ensure that the "DocException" message handler, in the API, will always either error or warn (depending on the build) if a valid Error isn't found
Having this present would have made debugging issues 11941 and 12209 so much quicker and easier.
2020-08-13 13:17:30 +02:00
Jonas Jenwald
22cb59e7d0 Wait until saving has finished before resetting PDFViewerApplication._saveInProgress (PR 12137 follow-up)
I obviously missed this during review, but currently `PDFViewerApplication._saveInProgress` is reset *synchronously* in `PDFViewerApplication.save`.
That was probably not intended, since it essentially renders the `PDFViewerApplication._saveInProgress` check pointless given that the actual saving is an *asynchronous* operation.
2020-08-13 13:00:29 +02:00
Jonas Jenwald
ea5581b70a Keep the original class/function names when minifying code (issue 12209)
While this will obviously increase the size of the output of `gulp minified`/`gulp minified-es5` *slightly*, the resulting files are still a lot smaller than the non-minified builds.

See https://github.com/terser/terser#minify-options for information about various Terser options.
2020-08-13 11:27:58 +02:00
Brendan Dahl
e50cb4c9d5
Merge pull request #12201 from brendandahl/enable-forms
Enable renderInteractiveForms by default.
2020-08-12 15:20:52 -07:00
Kartikaya Gupta
213676b5e8 Bug 1392361 - Fix zooming sensitivity on macOS
The original code would get a long sequence of miniscule "tick" values while
pinch-zooming, and each tick value would cause a 1.1x zoom. So even the smallest
pinch gesture on a trackpad would cause high amounts of zoom. This patch
accumulates the wheel deltas until they reach an integer threshold (with a
tweak of the scaling factor to make it feel more natural) at which point it
triggers the zoom based on the integer component of the accumulated delta. The
fractional part is retained in the accumulator.
2020-08-12 17:18:50 -04:00
Brendan Dahl
da62be0685 Enable renderInteractiveForms by default. 2020-08-12 10:28:27 -07:00
Brendan Dahl
7edc5cb79f
Merge pull request #12137 from calixteman/save
Add support for saving forms
2020-08-12 07:56:05 -07:00
Calixte Denizet
1a6816ba98 Add support for saving forms 2020-08-12 10:32:59 +02:00
Tim van der Meij
3380f2a7fc
Merge pull request #12191 from Snuffleupagus/rm-AppOptions-disableCreateObjectURL
Remove the `disableCreateObjectURL` option from `web/app_options.js`
2020-08-12 00:08:27 +02:00
Tim van der Meij
ac654db089
Merge pull request #12193 from Snuffleupagus/printContainer-canvas-direction
Set `direction: ltr;` on the canvases used during printing (bug 1335712)
2020-08-11 23:52:12 +02:00
Tim van der Meij
57c988853b
Merge pull request #12192 from Snuffleupagus/misc-AnnotationStorage-improvements
A couple of (small) tweaks of the `AnnotationStorage` (PR 12173 follow-up)
2020-08-11 23:46:13 +02:00
Brendan Dahl
7fb01f9f2a
Merge pull request #12186 from brendandahl/loca-2
Fix bad truetype loca tables.
2020-08-10 20:34:19 -07:00
Brendan Dahl
f6dff81223 Fix bad truetype loca tables.
Some fonts have loca tables that aren't sorted or use 0 as an offset to
signal a missing glyph. This fixes the bad loca tables by sorting them
and then rewriting the loca table and potentially re-ordering the glyf
table to match.

Fixes #11131 and bug 1650302.
2020-08-10 14:15:49 -07:00
Jonas Jenwald
8e32c17e85 Set direction: ltr; on the canvases used during printing (bug 1335712)
This essentially mirrors the CSS rules used for the viewer itself, see `web/pdf_viewer.css`, and according to my very quick tests it seems to fix https://bugzilla.mozilla.org/show_bug.cgi?id=1335712
2020-08-10 18:35:56 +02:00
Jonas Jenwald
4d351eab93 A couple of (small) tweaks of the AnnotationStorage (PR 12173 follow-up)
- Initialize the `AnnotationStorage`-instance, on `PDFDocumentProxy`, lazily.
 - Change the `AnnotationStorage` to use a `Map` internally, rather than a regular Object (simplifies the following points).
 - Let `AnnotationStorage.getAll` return `null` when there's no data stored, to avoid unnecessary parsing on the worker-thread. This ought to "just work", since the worker-thread code *should* already handle the `!annotationStorage` case everywhere.
 - Add a new `AnnotationStorage.size` getter, to be able to easily tell if there's any data stored.
2020-08-10 17:07:24 +02:00
Jonas Jenwald
5b94ed5487 Remove the disableCreateObjectURL option from web/app_options.js
Prior to PR 11601, the `disableCreateObjectURL` option was present on `getDocument` in the API, since it was (potentially) used when decoding JPEG images natively in the browser. Hence setting this option, which was done automatically using compatibility-code, were in some browsers necessary in order for e.g. JPEG images to be correctly rendered.

The downside of the `disableCreateObjectURL` option is that memory usage increases significantly, since we're forced to build and use `data:` URIs (rather than `blob:` URLs).
However, at this point in time the `disableCreateObjectURL` option is only necessary for *some* (non-essential) functionality in the default viewer; in particular:
 - The openfile functionality, used only when manually opening a new file in the default viewer.
 - The download functionality, used when downloading either the PDF document itself or its attached files (if such exists).
 - The print functionality, in the generic `PDFPrintService` implementation.

Hence neither the general PDF.js library, nor the *basic* functionality of the default viewer, depends on the `disableCreateObjectURL` option any more; which is why I'm thus proposing that we remove the option since using it is a performance footgun.

*Please note:* To not outright break currently "supported" browsers, which lack proper `URL.createObjectURL` support, this patch purposely keeps the compatibility-code to explicitly disable `URL.createObjectURL` usage *only* for browsers which are known to not work correctly.[1]

While it's certainly possible that there's additional, likely older, browsers with broken `URL.createObjectURL` support, the last time that these types of problems were reported was over *three* years ago.[2]
Hence in the *very* unlikely event that additional problems occur, as a result of these changes, we can either add a new case in the compatibility-code or simply declare the affected browser as unsupported.

---
[1] Which are IE11 (see issue 3977), and Google Chrome on iOS (see PR 8081).

[2] Given that `URL.createObjectURL` is used by default, you'd really expect more reports if these problems were widespread.
2020-08-10 15:56:30 +02:00
Tim van der Meij
6620861c7d
Merge pull request #12177 from calixteman/comb
Support comb textfields for printing
2020-08-09 15:44:21 +02:00
Calixte Denizet
88b112ab0c Support comb textfields for printing 2020-08-09 14:41:26 +02:00
Tim van der Meij
b061c300b4
Merge pull request #12176 from calixteman/multiline
Support multiline textfields for printing
2020-08-09 13:37:36 +02:00
Tim van der Meij
85c08ecdbd
Merge pull request #12188 from Snuffleupagus/update-packages
Update packages and translations
2020-08-09 12:40:11 +02:00
Calixte Denizet
cd8bb7293b Support multiline textfields for printing 2020-08-09 12:14:34 +02:00
Jonas Jenwald
7afcdbeebe Update l10n files 2020-08-09 11:05:40 +02:00
Jonas Jenwald
c1253fd2d9 Update npm packages 2020-08-09 11:03:07 +02:00
Tim van der Meij
ea29d4e0d4
Merge pull request #12187 from Snuffleupagus/issue-4398-test
Add a test-case for issue 4398
2020-08-08 17:45:44 +02:00
Tim van der Meij
1f8b54b1fe
Merge pull request #12154 from jsg2021/issue-8271
[api-minor] Allow loading pdf fonts into another document.
2020-08-08 17:43:49 +02:00
Jonas Jenwald
128e41d6be Add a test-case for issue 4398
Issue 4398 was fixed by PR 4437, however a test-case wasn't included as far as I can tell. Given that PR 12186 is now in the process of re-factoring that code, adding a test-case cannot hurt as far as I'm concerned.
2020-08-08 11:50:19 +02:00
Jonathan Grimes
ac723a1760 Allow loading pdf fonts into another document. 2020-08-08 02:52:32 +00:00
Tim van der Meij
fea40442f7
Merge pull request #12182 from tamuratak/fix_destroy
Fix the type of PDFDocumentLoadingTask.destroy.
2020-08-07 23:51:41 +02:00
Takashi Tamura
4ac62d8787 Fix the type of PDFDocumentLoadingTask.destroy. 2020-08-07 16:10:19 +09:00
Tim van der Meij
8c162f57f7
Merge pull request #12175 from calixteman/textfield
Support textfield and choice widgets for printing
2020-08-07 00:20:29 +02:00
Tim van der Meij
1f79c9834d
Merge pull request #12169 from Snuffleupagus/BaseTreeViewer-2
Extract common methods from `PDFOutlineViewer`/`PDFAttachmentViewer` into a new abstract `BaseTreeViewer` class
2020-08-06 23:14:11 +02:00
Tim van der Meij
b99b3b6ab7
Merge pull request #12179 from Snuffleupagus/Object.fromEntries
Add support for `Object.fromEntries`
2020-08-06 22:55:34 +02:00