Commit Graph

10547 Commits

Author SHA1 Message Date
Jonas Jenwald
2bc3d0ff91
Merge pull request #9360 from mmcev106/master
Fixed a javascript error in the mobile viewer example that prevented …
2018-01-17 11:32:48 +01:00
Mark McEver
c8344016fa Fixed a javascript error in the mobile viewer example that prevented an alert from being displayed 2018-01-16 15:36:54 -06:00
Andy Chou
b867c3299b end() is the official way to release a Writable stream 2018-01-16 12:01:33 -08:00
Tim van der Meij
1ad33c4514
Merge pull request #9364 from shikhar-scs/change-decodeURI-to-decodeURIcomponent
changed decodeURI to decodeURIComponent: Fixes #8987
2018-01-15 22:05:48 +01:00
shikhar-scs
32080f1081 changed decodeURI to decodeURIComponent 2018-01-15 19:31:25 +05:30
Tim van der Meij
237bc2ef9d
Merge pull request #9323 from juncaixinchi/master
Get correct path in node_stream on windows platform( issue #9020)
2018-01-14 15:41:56 +01:00
Rob Wu
1c8cacd6b9 Limit PDFFetchStream to http(s) in the Chrome extension
The `fetch` API is only supported for http(s), even in Chrome extensions.
Because of this limitation, we should use the XMLHttpRequest API when the
requested URL is not a http(s) URL.

Fixes #9361
2018-01-14 00:34:46 +01:00
Tim van der Meij
a7cb560f17
Merge pull request #9343 from Snuffleupagus/btoa/atob-Node-polyfills
Restore the `btoa`/`atob` polyfills for Node.js
2018-01-13 15:52:31 +01:00
juncaixinchi
8e278d9a45 Get correct path in node_stream on windows platform 2018-01-13 21:13:24 +08:00
Jonas Jenwald
0e1b5589e7 Restore the btoa/atob polyfills for Node.js
These were removed in PR 9170, since they were unused in the browsers that we'll support in PDF.js version `2.0`.
However looking at the output of Travis, where a subset of the unit-tests are run using Node.js, there's warnings about `btoa` being undefined. This doesn't appear to cause any errors, which probably explains why we didn't notice this before (despite PR 9201).
2018-01-13 01:31:05 +01:00
Tim van der Meij
ba0a3aebd0
Merge pull request #9356 from Snuffleupagus/PDFHistory-maxUid-pageHide-fixes
Two small `PDFHistory` fixes, concerning the `this._maxUid` property and the 'pagehide' event
2018-01-12 22:07:15 +01:00
Brendan Dahl
d77fc8882a
Merge pull request #9352 from Snuffleupagus/issue-9285
Attempt to actually resolve ColourSpace names in accordance with the specification (issue 9285)
2018-01-12 13:01:22 -08:00
Jonas Jenwald
e20eacd484 Allow overwriting temporary, in addition to empty, history entries on 'pagehide'
When navigating away from the viewer, there's no good reason for disallowing replacement of a *temporary* history entry (in addition to empty ones).

Given that the current position is temporarily added to the browser history using a (short) timeout, the history entry will most likely already be correct when the 'pagehide' event fires. However, if the user is quick enough that might not always be the case, in which case the adjusted logic may help.
2018-01-11 12:34:19 +01:00
Jonas Jenwald
448a7a27cb Ensure that the PDFHistory._maxUid property is correctly updated when initializing/navigating the history
This is a follow-up to commit e772124339, in PR 8994, to cover a couple of cases missed there.
2018-01-11 12:09:01 +01:00
Jonas Jenwald
d0c8992e8a Attempt to actually resolve ColourSpace names in accordance with the specification (issue 9285)
Please refer to the PDF specification, in particular http://www.adobe.com/content/dam/acom/en/devnet/acrobat/pdfs/PDF32000_2008.pdf#G7.3801570

> A colour space shall be specified in one of two ways:
>  - Within a content stream, the CS or cs operator establishes the current colour space parameter in the graphics state. The operand shall always be name object, which either identifies one of the colour spaces that need no additional parameters (DeviceGray, DeviceRGB, DeviceCMYK, or some cases of Pattern) or shall be used as a key in the ColorSpace subdictionary of the current resource dictionary (see 7.8.3, "Resource Dictionaries"). In the latter case, the value of the dictionary entry in turn shall be a colour space array or name. A colour space array shall never be inline within a content stream.
>
> - Outside a content stream, certain objects, such as image XObjects, shall specify a colour space as an explicit parameter, often associated with the key ColorSpace. In this case, the colour space array or name shall always be defined directly as a PDF object, not by an entry in the ColorSpace resource subdictionary. This convention also applies when colour spaces are defined in terms of other colour spaces.
2018-01-10 20:20:43 +01:00
Jonas Jenwald
5a52ee0a79
Merge pull request #9350 from janpe2/svg-closeEOFillStroke
Implement `closeEOFillStroke` in SVG backend
2018-01-09 21:09:11 +01:00
Brendan Dahl
3925aab010
Merge pull request #9282 from Snuffleupagus/TrueType-Collection
Add support for TrueType Collection fonts (issue 9262)
2018-01-09 11:22:52 -08:00
Jani Pehkonen
d1e1dbfc14 Implement closeEOFillStroke in SVG backend 2018-01-09 19:42:12 +02:00
Jonas Jenwald
915e3f4c5f
Merge pull request #9099 from tiriana/allow-dontFlip-in-PDFPageProxy-getViewport
Allows 'dontFlip' as third arg in PDFPageProxy.getViewport
2018-01-09 18:27:26 +01:00
Radomir Wojtera
3dfc540d04 Allows 'dontFlip' as third argument in PDFPageProxy.getViewport 2018-01-09 13:08:24 +01:00
Jonas Jenwald
d6c028b946 Add support for TrueType Collection fonts (issue 9262)
The specification can be found at https://www.microsoft.com/typography/otspec/otff.htm, under the "Font Collections" heading.

Fixes 9262.
2018-01-08 22:31:08 +01:00
Tim van der Meij
a3b2456c7a
Merge pull request #9339 from bansalnitish/enter-key
Added enter key functionality for presentation mode
2018-01-05 22:55:06 +01:00
Nitish Bansal
d60cba5065 Added enter key functionality for presentation mode 2018-01-05 03:27:14 +05:30
Tim van der Meij
6b2ed504b7
Merge pull request #9336 from Snuffleupagus/jpx-SIZ
Correctly extract component data from "Image and tile size" (SIZ) markers in JPEG 2000 images
2018-01-03 23:34:34 +01:00
Tim van der Meij
f475a0576c
Merge pull request #9335 from Snuffleupagus/eslint-no-multiple-empty-lines
Update the ESLint dependencies, and also tweak the `no-multiple-empty-lines` rules
2018-01-03 23:30:50 +01:00
Jonas Jenwald
873556865b Correctly extract component data from "Image and tile size" (SIZ) markers in JPEG 2000 images
This is something that I noticed while attempting to debug https://bugzilla.mozilla.org/show_bug.cgi?id=1374945.
Just looking at the code, the `YRsiz` parameter seemed immediately wrong and the fact that every component used the *same* data also looked strange.
Comparing with the specification, see https://www.itu.int/rec/dologin_pub.asp?lang=e&id=T-REC-T.800-200208-S!!PDF-E&type=items#page=37, confirmed that this is indeed incorrect.

Note that I haven't got any example of a PDF file that is fixed by this patch, but that might be more luck than anything else. Manually checking a couple of files with included JPEG 2000 images, the `Csiz`/`XRsiz`/`YRsiz` parameters were `1` which could explain why this hasn't been an issue before.

Obviously we shouldn't generally make changes to `core` code without adding tests, but in this case I'm simply not sure how to obtain/create one. However, since the existing code doesn't make sense this patch could hopefully be deemed acceptable anyway.
2018-01-03 16:26:28 +01:00
Jonas Jenwald
2db75a2a3a Update the ESLint dependencies, and also tweak the no-multiple-empty-lines rules
Since multiple empty lines is virtually unused in the code-base, and the few cases that do exist look like "typos", let's enforce greater consistency here; please see https://eslint.org/docs/rules/no-multiple-empty-lines.
2018-01-03 13:32:57 +01:00
Tim van der Meij
25c7a8c215
Merge pull request #9331 from himanish-star/replace-num-pageNum
local num used instead of global pageNum (#9328)
2018-01-02 22:18:35 +01:00
Soumya Himanish Mohapatra
a9fd1e7392 num(local) used instead of pageNum(global) in prevnext.html for enhancement of logic 2018-01-02 20:22:18 +05:30
Jonas Jenwald
5bf4fb979e Update l10n files 2018-01-01 10:19:59 +01:00
Jonas Jenwald
ae65c66133
Merge pull request #9330 from timvandermeij/custom-style
Remove the `CustomStyle` class
2017-12-31 15:24:21 +01:00
Tim van der Meij
d36c46b2c9
Remove the CustomStyle class
It is only used in a few places to handle prefixing style properties if
necessary. However, we used it only for `transform`, `transformOrigin`
and `borderRadius`, which according to Can I Use are supported natively
(unprefixed) in the browsers that PDF.js 2.0 supports. Therefore, we can
remove this class, which should help performance too since this avoids
extra function calls in parts of the code that are called often.
2017-12-31 14:22:11 +01:00
Jonas Jenwald
3f88bfcda6
Merge pull request #9329 from timvandermeij/gulp-util
Stop using the deprecated `gulp-util` module
2017-12-31 12:42:59 +01:00
Tim van der Meij
d688b8ea31
Stop using the deprecated gulp-util module
The `gulp-util` module is now deprecated and authors are asked to stop
using it (refer to https://medium.com/gulpjs/gulp-util-ca3b1f9f9ac5 for
more information).

PDF.js does not rely on it that much, fortunately, so it's relatively
easy for us to remove the dependency. This patch does that by making the
following changes:

- Require `gulp-zip` version 4.1.0 or higher since they already removed
  their `gulp-util` dependency in that version.
- Replace `gulp-util.log` with the `fancylog` module as recommended in
  the article above.
- Replace `gulp-util.File` with the `Vinyl` module as recommended in the
  article above.

The only change I had to make for Vinyl is removing the `base` and `cwd`
lines since they may not be empty strings anymore. This way we fall back
to the defaults Vinyl provides, which for us doesn't matter since we
move the file afterwards anyway. Moreover, I used `vfs` for `vinyl-fs`
in the `Gulpfile` to avoid confusion with `vinyl` (which is also how the
documentation names the variable).

This is all we can do on our side; the other modules that still use
`gulp-util` must be updated upstream.
2017-12-30 20:13:52 +01:00
Tim van der Meij
4cc0f8c721
Merge pull request #9325 from Snuffleupagus/decodeACSuccessive-less-blur
Adjust `decodeACSuccessive` in src/core/jpg.js to improve the rendering quality of (progressive) JPEG images
2017-12-30 19:26:07 +01:00
Jonas Jenwald
c5700211d6 Adjust decodeACSuccessive in src/core/jpg.js to improve the rendering quality of (progressive) JPEG images
I've been looking into the remaining point in 8637 about blurry images, to see if we could perhaps improve the rendering quality slightly there. After quite a bit of debugging, it seems that the issue is limited to certain progressive JPEG images.

As mentioned previously, I've got no detailed knowledge of the JPEG format, but this patch does seem to improve things quite a bit for the images in question.
Squinting at https://searchfox.org/mozilla-central/rev/6c33dde6ca02b389c52e8db3d22494df8b916f33/media/libjpeg/jdphuff.c#492-639, it seems reasonable that we should take the sign of the data into account. Furthermore, looking at the specification in https://www.w3.org/Graphics/JPEG/itu-t81.pdf#page=118, the "F.2.4.3 Decoding the binary decision sequence for non-zero DC differences and AC coefficients" section even contains a description of this (even though I cannot claim to really understand the details).
2017-12-30 15:24:09 +01:00
Jonas Jenwald
d6eed132e5 Correct the indentation in the switch statement in decodeACSuccessive in src/core/jpg.js 2017-12-30 15:22:30 +01:00
Tim van der Meij
18d82d9c54
Merge pull request #9287 from himanish-star/PDFjs-compatible-Librejs
PDFjs now compatible with Librejs
2017-12-30 14:00:25 +01:00
Tim van der Meij
ad0dc7e89a
Merge pull request #9327 from Snuffleupagus/JpegStream-DeviceGray-length
Avoid truncating JPEG images with DeviceGray ColourSpaces when using the `src/core/jpg.js` built-in decoder
2017-12-29 22:31:35 +01:00
Jonas Jenwald
8c4b7d0439 Avoid truncating JPEG images with DeviceGray ColourSpaces when using the src/core/jpg.js built-in decoder
The bug that this patch fixes is limited to the built-in JPEG decoder, and was unearthed by PR 9260. The underlying issue has existed since PR 6984, where the contents of this patch ought to have been included (if it weren't for the fact that we had no *easy* way to test `src/core/jpg.js` back then).

*Please note:* The slight movement in the reference test is a result of using the `src/core/jpg.js` decoder, rather than the native browser one.
2017-12-29 18:44:07 +01:00
Tim van der Meij
25bbff4692
Merge pull request #9320 from Snuffleupagus/pr-9095-followup
Avoid rendering errors by passing in the `webGLContext` when creating a new `CanvasGraphics` in `getColorN_Pattern` (PR 9095 follow-up)
2017-12-28 23:17:30 +01:00
Tim van der Meij
5c2cd369d2
Merge pull request #9321 from Snuffleupagus/rm-IE-linkAnnotation-hack
Remove the `background` compatibility hacks for `linkAnnotation` in old versions of IE
2017-12-28 00:08:12 +01:00
Jonas Jenwald
ec21bd9626
Merge pull request #9314 from timvandermeij/encodings
Implement unit tests for the encodings and fix missing items
2017-12-27 22:02:38 +01:00
Jonas Jenwald
03b0c76b7f Remove the background compatibility hacks for linkAnnotation in old versions of IE
With PDF.js version `2.0` we'll no longer support IE 9 and 10, hence these hacks can now be removed.
2017-12-27 14:16:28 +01:00
Jonas Jenwald
06605abbc2 Avoid rendering errors by passing in the webGLContext when creating a new CanvasGraphics in getColorN_Pattern (PR 9095 follow-up)
This was an oversight in PR 9095, which unfortunately breaks rendering in some PDF files (e.g. the one from issue 6737).

It thus appears that we don't have any test-coverage for this code-path, and given the relative complexity of the PDF files affected by this bug I wasn't able to easily create a reduced test-case.
*Please note:* The linked test-case included in this patch is currently *not* rendered correctly (that'd be the PR 6606), but it at least gives us some test-coverage here.
2017-12-27 13:50:53 +01:00
Tim van der Meij
fe30d4d468
Merge pull request #9313 from Snuffleupagus/issue-9291
Add a fallback for non-embedded LucidaSans-Demi fonts (issue 9291)
2017-12-24 20:06:38 +01:00
Tim van der Meij
c7af2db2ec
Implement unit tests for the encodings and fix missing items
Initially I just implemented the unit tests, but quickly found that they
were failing my expectation of having a size of 256 items. Some of them
did contain 256 items and some did not. I looked up various resources
and figured that they indeed all need to have 256 items. One of the good
resources is https://github.com/davidben/poppler/blob/master/poppler/FontEncodingTables.cc

Aside from some missing `notdef` (empty string) entries at the end of
the arrays, which I assume causes issues since it may cause
out-of-bounds array access which in JavaScript gives `undefined`, there
was a `notdef` entry missing in the `MacExpertEncoding`, causing the
entries after that to be shifted. This fix for this is similar to the
one in #8589.

The unit tests verify that, for known encoding names, the return value
is not only an array, but that it is also of the right length and
contains only strings.
2017-12-24 18:14:40 +01:00
Jonas Jenwald
d4cd44fd16 Add a fallback for non-embedded LucidaSans-Demi fonts (issue 9291)
The PDF file in the issue uses a number of *embedded* versions of Lucida fonts, but for some reason does *not* embed the LucidaSans-Demi font. According to https://en.wikipedia.org/wiki/Lucida#Usages that one should be bold, so we can at least improve rendering here (even though it won't look perfect).

Fixes 9291.
2017-12-24 17:36:58 +01:00
Tim van der Meij
1d4651b2e4
Merge pull request #9311 from timvandermeij/unit-test-network-utils
Implement unit tests for the network utility code
2017-12-23 19:36:24 +01:00
Tim van der Meij
957e2d420d
Implement unit tests for the network utility code
This should provide 100% coverage for the file.
2017-12-23 19:24:11 +01:00