Commit Graph

9185 Commits

Author SHA1 Message Date
Tim van der Meij
c8158dc672 Merge pull request #7771 from timvandermeij/l10n-updates
Localization updates
2016-10-31 23:44:55 +01:00
Tim van der Meij
775b294bb9 L10n: import upstream translations 2016-10-31 23:35:05 +01:00
Tim van der Meij
f8e29ad80f L10n: update the Dutch translation after recent string changes 2016-10-31 23:31:14 +01:00
Jonas Jenwald
077e644437 Fix a typo in the page_of_pages l10n ID for the en-US locale 2016-10-31 23:14:22 +01:00
Tim van der Meij
e9c63a2b32 Merge pull request #6945 from Snuffleupagus/page-labels-viewer
Add support for PageLabels in the viewer (issue 6902, bug 793632)
2016-10-31 22:59:56 +01:00
Yury Delendik
a740d69457 Merge pull request #7766 from Rob--W/printing-refactor-split-from-7721
Printing refactor split from 7721
2016-10-31 08:51:49 -05:00
Rob Wu
594592216c Refactor printing: startPrint -> performPrint
- Renamed startPrint to performPrint to emphasize that the method
  does not start the print process (preparing pages for the printer),
  but that it does the actual printing (sending pages off to the
  printer).

- Put performPrint in the PDFPrintService, so that it can be
  overridden if needed.
2016-10-30 12:03:24 +01:00
Rob Wu
d3b13e36d3 Refactor page printing logic on the web
- Move the global scratchCanvas to PDFPrintService. This is mainly to
  make it easier to reason about the state of scratchCanvas. In practice
  there is no difference because only one PDFPrintService instance can
  be instantiated at any given time.

- Move all logic of using the rendered page to one location.
  This makes it easier to replace the printing logic later, when I add
  special handling to out-of-process frames in the Chrome extension.
2016-10-30 12:03:24 +01:00
Rob Wu
0c21ebf9f3 Close overlay if print service was not initialized
Fixes #7720
2016-10-30 12:03:24 +01:00
Rob Wu
1c869906c8 Strictly manage lifetime of PDFPrintService
Make sure that the print service is stopped as soon as possible when
aborted, and that it is not possible for a (slow) promise to
accidentally wipe the state of a print job that was started later.
2016-10-30 12:03:24 +01:00
Tim van der Meij
1c3fb175dd Merge pull request #7757 from Snuffleupagus/setHash-remove-pageNumber-directly-after-hash
Remove/deprecate specifying a pageNumber directly after the hash symbol (#), to improve compatibility since other PDF viewers don't support this form (issue 7746)
2016-10-27 23:56:23 +02:00
Jonas Jenwald
87c2ff5483 Remove/deprecate specifying a pageNumber directly after the hash symbol (#), to improve compatibility since other PDF viewers don't support this form (issue 7746)
There's no mention of our `#{pagenum}` form in http://www.adobe.com/content/dam/Adobe/en/devnet/acrobat/pdfs/pdf_open_parameters.pdf, and Adobe Reader doesn't seem to support it either.
Hence this patch removes support for it in the extensions, but keeps it in the `GENERIC` build with a deprecation warning and a fallback to handle it as a destination.

Fixes 7746.
2016-10-27 23:25:53 +02:00
Yury Delendik
ab464df336 Import L10n files. 2016-10-27 16:16:27 -05:00
Tim van der Meij
abc417cee9 Merge pull request #7750 from Snuffleupagus/PDFLinkService_navigateTo-more-validation
Add more validation to `PDFLinkService_navigateTo`
2016-10-27 22:16:35 +02:00
Tim van der Meij
a28a71072d Merge pull request #7756 from timvandermeij/npm
Travis CI: use most recent version of NPM
2016-10-27 21:19:03 +02:00
Tim van der Meij
7c78b2f6c0 Travis CI: use most recent version of NPM 2016-10-27 21:10:19 +02:00
Tim van der Meij
e94c2945af Merge pull request #7749 from Snuffleupagus/PDFLinkService_setHash-dest-fallback
Avoid accidentally rejecting a named destination that looks like a decimal number or a boolean (PR 7341 follow-up)
2016-10-27 16:14:28 +02:00
Jonas Jenwald
efb9619e53 Add PageLabels to PDFPageView and PDFThumbnailView 2016-10-26 13:30:37 +02:00
Jonas Jenwald
f461fd64aa Add support for PageLabels in the viewer
This patch implements the page label functionality in a similar way as Adobe Reader.
For documents with page labels, if a non-existent page label is entered we'll try to fallback to the page number instead.
The patch also includes a preference (`disablePageLabels`), to make it easy to opt-out of using page labels if the user/implementor so wishes.

The way that `get/set currentPageLabel` is implemented in `PDFViewer`, is as wrappers for the corresponding `get/set currentPageNumber` functions, since that seemed like the cleanest solution.
The page labels are purposely *only* added to the page controls in the viewer UI, and not stored in e.g. the `ViewHistory`. Since doing so would mean adding unnecessary code complexity, without any real added value, and would also mean delaying the inital loading of PDF documents.

Note that this patch will ignore page labels if they are identical to standard page numbering, since in this case displaying the page labels adds no value (but only UI noise). The reason for handling this case specially, is that in practice a surprising number of PDF files include "pointless" page labels.
2016-10-26 13:30:36 +02:00
Jonas Jenwald
23ec02bb93 Remove the "Page: " label and replace it with a tooltip
The following reasoning was used for deciding to remove the "Page: " label, and replace it with a tooltip, from the main toolbar:
 - We have no other visible labels in the *main* toolbar (e.g. the Zoom dropdown doesn't have a label, but only a tooltip).
 - We already hide the "Page: " label when the viewer is narrow.
 - The varying width of the "Page: " label in different locales is already causing issues for many languages, with overlap in the main toolbar as a result.
Trying to create responsive CSS styles that works well in all locales is already difficult, and if we add support for page labels that will only further compound the issues.
 - Some PDF viewers (e.g. Adobe Reader, pdfium in Chrome) doesn't show labels in the UI by default.
2016-10-26 13:30:26 +02:00
Jonas Jenwald
e1412de320 Add more validation to PDFLinkService_navigateTo
In some PDF files, the first element (i.e. the one containing either a `Ref` or a `Number` pointing to a page) of the explicit destination Array may be bogus.

One such example is actually the file `pdf.pdf` in the test-suite, where some destinations are incompletely specified. One such example being the `G1.998360` destination whose explicit destination Array contains `[null, /XYZ, 54, 488, null]`, i.e. the destination page is `null`.
Hence this patch adds a bit more validation for that case. It also adds an additional check to ensure that the resulting `pageNumber` is non-negative, and finally a couple more error messages for existing cases of malformed data.
2016-10-24 10:22:45 +02:00
Jonas Jenwald
d5e3b2fbf0 Update PDFOutlineViewer_bindLink to look more like LinkAnnotationElement_bindLink 2016-10-23 16:08:26 +02:00
Jonas Jenwald
47a1c7797e Update l10n files 2016-10-23 12:19:00 +02:00
Jonas Jenwald
901a2d41be Avoid accidentally rejecting a named destination that looks like a decimal number or a boolean (PR 7341 follow-up)
Without this patch, the following link does not work correctly: http://unesdoc.unesco.org/images/0013/001346/134685E.pdf#4.3
Compare the correct behaviour of this link: http://unesdoc.unesco.org/images/0013/001346/134685E.pdf#nameddest=4.3
2016-10-23 11:55:27 +02:00
Jonas Jenwald
7e392c0205 Merge pull request #7689 from Snuffleupagus/relative-URLs
[api-minor] Add support for relative URLs, in both annotations and the outline, by adding a `docBaseUrl` parameter to `PDFJS.getDocument` (bug 766086)
2016-10-19 22:51:09 +02:00
Jonas Jenwald
d284cfd5eb [api-minor] Add support for relative URLs, in both annotations and the outline, by adding a docBaseUrl parameter to PDFJS.getDocument (bug 766086)
Note that in `FIREFOX/MOZCENTRAL/CHROME` builds of the standard viewer the `docBaseUrl` parameter will be set by default, since in that case it makes sense to use the current URL as a base.
For the `GENERIC` viewer, or the API itself, it doesn't make sense to try and set the `docBaseUrl` by default. However, custom deployments/implementations may still find the parameter useful.
2016-10-19 22:20:24 +02:00
Jonas Jenwald
71a781ee5c Deprecate the isValidUrl utility function and replace it with createValidAbsoluteUrl/isValidProtocal functions instead, since the main URL validation is now done using the new URL constructor 2016-10-19 22:11:22 +02:00
Jonas Jenwald
42f07c6262 [api-minor] Use the new URL constructor when validating URLs in annotations and the outline, as a complement to only checking the protocol, and add a bit more validation to Catalog_parseDestDictionary
Note that this will automatically reject any relative URL.
To make the API more useful to consumers, URLs that are rejected will be available via the `unsafeUrl` property in the data object returned by `PDFPageProxy_getAnnotations`.

The patch also adds a bit more validation of the data for `Named` actions.
2016-10-19 22:11:17 +02:00
Jonas Jenwald
e64bc1fd13 Move parsing of destination dictionaries to a helper function
This not only reduces code duplication, but it also allow us to easily support the same kind of URLs we currently do for Link annotations in the Outline as well.
2016-10-18 16:14:07 +02:00
Tim van der Meij
6906623462 Merge pull request #7717 from jeenuv/display-double-click-tooltip
Explain double-click behaviour on tool tip
2016-10-18 13:52:31 +02:00
Tim van der Meij
1783f14511 Merge pull request #7732 from yurydelendik/svg-cgrp
Removes SVG this.cgrp usages.
2016-10-18 00:57:52 +02:00
Yury Delendik
1236b27993 Removes SVG this.cgrp usages. 2016-10-17 16:09:24 -05:00
Yury Delendik
273d2de6ec Merge pull request #7715 from timvandermeij/svg-groups
SVG: optimize and refactor group creation code
2016-10-17 10:10:47 -05:00
Tim van der Meij
960e344a8a Merge pull request #7730 from Snuffleupagus/jsdoc-typedef-property
Fix a couple of JSDoc `@typedef`s to use `@property` (instead of `@param`) to fix some missing documentation when running `gulp jsdoc`
2016-10-17 16:38:13 +02:00
Yury Delendik
1369997bbf Properly invoke 'gulp' in make.js and fail when it fails. 2016-10-17 08:47:05 -05:00
Yury Delendik
85db146525 Run 'firefox' and 'chromium' task in-sequences 2016-10-17 08:05:16 -05:00
Jonas Jenwald
2ce9da9b7a Fix a couple of JSDoc @typedefs to use @property (instead of @param) to fix some missing documentation when running gulp jsdoc 2016-10-17 13:04:55 +02:00
Jonas Jenwald
6678da379b Merge pull request #7728 from timvandermeij/gulp-port
Gulp: port the `all`, `extension` and `jsdoc` targets
2016-10-17 12:49:47 +02:00
Tim van der Meij
224e3a42a2 Gulp: port the all, extension and jsdoc targets
This requires the `run-sequence` dependency because Gulp does not have a
way to run sequences of tasks inside a Gulp task. Gulp 4.0 will have
support for this, but until that is released this is the recommended way
to implement it.
2016-10-16 22:17:25 +02:00
Jeenu Viswambharan
f2dcacd164 Explain double-click behaviour on tool tip
The outline toggle button has a feature where it can be double-clicked
to expand/collapse all items shown therein. Although this is described
in the FAQ, can go potentially unnoticed. This, however, being a useful
feature, advertise on the tool tip itself.

l10n translation for en-US and IDs updated.

Signed-off-by: Jeenu Viswambharan <jeenuv@gmail.com>
2016-10-16 09:22:48 +01:00
Tim van der Meij
426fc454de SVG: factor out initialization code into a private method
Each well-formed SVG image has the following structure:

SVG element
- Definitions element
- Root group
  - Other group 1
  - ...
  - Other group n

This patch factors out initialization code into a private method in such
as way that the creation of this structure is clear from the code. The
root group is the replacement for the parent group from before. We need
this group as we cannot apply the viewport transform on the SVG element
itself (this caused issues in Chrome). If other code appends groups to
the SVG image, in reality it is appending those groups to the root
group, but this detail is abstracted away by this patch.
2016-10-15 21:45:44 +02:00
Tim van der Meij
fa90573c4b SVG: optimize transform group creation
This patch ensures that we only create transformation groups when it is
actually required and that we re-use transform groups as much as possible.
It reduces the number of transform groups for the Tracemonkey paper from
2790 to 1271, thereby making the DOM much lighter and rendering/scrolling
smoother. Moreover, it simplifies the code and prevents duplication.

Finally, we issue a warning when an unimplemented graphic state is
encountered. Before, this was ignored silently, making debugging harder.
2016-10-15 21:43:12 +02:00
Tim van der Meij
de6c92a96d Examples: improve SVG viewer
This patch:

- resolves a warning in the console about missing character encoding;
- makes the viewer use the same background color and PDF file as the
  regular viewer;
- simplifies the example to bring it more in line with the other
  examples.
2016-10-15 21:08:24 +02:00
Tim van der Meij
2e20000b71 Merge pull request #7727 from Snuffleupagus/parser-stream-decodeParms
Let `Parser_makeFilter` pass in the `DecodeParms` data to various image `Stream`s, instead of re-fetching it in various `[...]Stream.prototype.ensureBuffer` methods
2016-10-15 20:04:17 +02:00
Yury Delendik
ea5949f1fd Merge pull request #7668 from Snuffleupagus/issue-7665
Prevent an infinite loop in `XRef_fetchUncompressed` for encrypted PDF files with indirect objects in the /Encrypt dictionary (issue 7665)
2016-10-15 10:52:08 -05:00
Jonas Jenwald
f209030b99 Merge pull request #7726 from Snuffleupagus/remove-remaining-preprocessor-statement-core-fonts
Remove a remaining old-style preprocessor from `src/core/fonts.js` (PR 7322 follow-up)
2016-10-15 13:46:23 +02:00
Jonas Jenwald
c8f83d6487 Let Parser_makeFilter pass in the DecodeParms data to various image Streams, instead of re-fetching it in various [...]Stream.prototype.ensureBuffer methods
In `Parser_filter` the `DecodeParms` data is fetched and passed to `Parser_makeFilter`, where we also make sure that a `Ref` is resolved to a direct object.
We can thus pass this along to the various image `Stream` constructors, to avoid the current situation where we lookup/resolve data that is already available.
Note also that we currently do *not* handle the case where `DecodeParms` is an Array entirely correct in the various image `Stream`s, and this patch fixes that for free.
2016-10-15 12:09:51 +02:00
Jonas Jenwald
1da59bec9b Remove a remaining old-style preprocessor from src/core/fonts.js (PR 7322 follow-up)
Note that this code was added *after* PR 7322 was opened, which thus explains why it was missed during rebasing.
2016-10-15 11:33:09 +02:00
Jonas Jenwald
c1a34ffbcd Merge pull request #7322 from yurydelendik/preproc2
Remove JS preprocessor code from the web/ and src/ files
2016-10-14 23:35:17 +02:00
Yury Delendik
0576c9c6c6 Replaces all preprocessor directives with PDFJSDev calls. 2016-10-14 10:57:53 -05:00