Commit Graph

12976 Commits

Author SHA1 Message Date
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
Calixte Denizet
1747d259f9 Support textfield and choice widgets for printing 2020-08-06 14:45:23 +02:00
Jonas Jenwald
16fa9dc4ea Add support for Object.fromEntries
This provides a simpler way of creating an `Object` from e.g. a `Map`, without having to manually iterate over it.
Please see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/fromEntries
2020-08-06 14:39:51 +02:00
Tim van der Meij
95e102c07b
Merge pull request #12173 from Snuffleupagus/render-annotationStorage
[api-minor] Fix the `annotationStorage` parameter in `PDFPageProxy.render`
2020-08-05 23:30:50 +02:00
Jonas Jenwald
54fc7058e4 Re-factor the "outlineloaded"/"attachmentsloaded" event handlers in PDFSidebar
With recent changes, these event handlers are now essentially identical. Hence a new helper function is added, to reduce unnecessary duplication (will also be helpful with upcoming changes).
2020-08-05 23:08:06 +02:00
Jonas Jenwald
6e9da55a39 Extract common methods from PDFOutlineViewer/PDFAttachmentViewer into a new abstract BaseTreeViewer class
These two classes are unsurprisingly quite similar, and with upcoming changes[1] the amount of (essentially) duplicated code will increase even further.

Notable changes:
 - Collect shared functionality in the `BaseTreeViewer` class, reducing both current and future code-duplication.
 - Reduce unnecessary duplication in the CSS rules, which will be particularly useful with upcoming changes.
 - Tweak the attachmentsView to use links, rather than buttons, to simplify (primarily) the CSS rules.

---
[1] Once API support for "Optional Content" lands, I've got more-or-less finished patches to add viewer support as well.
2020-08-05 23:08:06 +02:00
Jonas Jenwald
a6c1ef82ae Update BaseViewer.createAnnotationLayerBuilder, and PDFPageView, to accurately reflect IPDFAnnotationLayerFactory (PR 12147 follow-up) 2020-08-05 23:02:30 +02:00
Jonas Jenwald
5e44b241b2 [api-minor] Fix the annotationStorage parameter in PDFPageProxy.render
While the parameter name (clearly) suggests that an `AnnotationStorage`-instance is expected, looking at the only call-sites that include the parameter (i.e. the `PDFPrintServiceFactory` instances) it actually contains just a normal Object.

Hence it seems much more reasonable to actually pass a valid `AnnotationStorage`-instance, as the name suggests, and simply have `PDFPageProxy.render` do the `annotationStorage.getAll()` call. (Since we cannot send an `AnnotationStorage`-instance as-is to the worker-thread, given the "structured clone algorithm".)
2020-08-05 23:02:30 +02:00
Tim van der Meij
a289eb8325
Merge pull request #12174 from Snuffleupagus/AppOptions-printResolution
Do the `AppOptions.get("printResolution")` lookup once in `web/app.js `, when initializing `PDFPrintServiceFactory`-instances, rather than for every printed page
2020-08-05 22:47:37 +02:00
Tim van der Meij
66d5345dea
Merge pull request #12172 from tamuratak/fix_typedarray
Fix the type definition of TypedArray. (PR 12156 follow-up)
2020-08-05 22:39:10 +02:00
Jonas Jenwald
97d796e372 Do the AppOptions.get("printResolution") lookup once in web/app.js, when initializing PDFPrintServiceFactory-instances, rather than for every printed page
There's really no point in repeating these lookups over and over, since the value should be constant for the duration of one print invocation anyway.
2020-08-05 13:34:09 +02:00
Takashi Tamura
a0f0ab78f3 Fix the type definition of TypedArray. 2020-08-05 17:01:08 +09:00
Tim van der Meij
63e33a5895
Merge pull request #12168 from Snuffleupagus/fix-types
Fix the `gulp types` task to run on Windows, and place the TypeScript definitions correctly in `pdfjs-dist`
2020-08-05 00:26:11 +02:00
Tim van der Meij
02bcc25b9f
Merge pull request #12171 from Snuffleupagus/unittest-shall_fail_rendering
Attempt to reduce intermittent failures in the "multiple render() on the same canvas" unit-test
2020-08-05 00:02:39 +02:00
Tim van der Meij
85982c45dc
Merge pull request #12163 from Snuffleupagus/improve-PDFAttachmentViewer-render
Re-factor the dispatching of "attachmentsloaded" events, when the PDF document contains no "regular" attachments
2020-08-04 23:59:20 +02:00
Jonas Jenwald
fb85c2dc6d Fix the gulp types task to run on Windows, and place the TypeScript definitions correctly in pdfjs-dist
- Fix the `gulp types` task to run on Windows. Currently this fails, and the solution was to "borrow" the same formatting as used in the `gulp jsdoc` task.

 - Place the TypeScript definitions in their own `types` directory, when building `pdfjs-dist`. These should *not* be cluttering the main `build` directory, especially since the generated TypeScript definitions consists of *multiple folders*. (Only if the TypeScript definitions would be concatenated into *a single file*, would placing them directly in `pdfjs-dist/build` be acceptable.)
2020-08-04 23:50:04 +02:00
Tim van der Meij
71f8e1f538
Merge pull request #12156 from timvandermeij/types-followup
Improve the types generation and API documentation (PR 12102 follow-up)
2020-08-04 23:40:44 +02:00