Commit Graph

10050 Commits

Author SHA1 Message Date
Jonas Jenwald
e2ea9b693c In src/core/jpg.js, ensure that the Adobe JPEG marker always takes precedence, even when the color transform code is zero
According to the PDF specification, please see http://www.adobe.com/content/dam/Adobe/en/devnet/acrobat/pdfs/PDF32000_2008.pdf#G6.2394361, if an Adobe JPEG marker is present it should always take precedence. This even seem to be consistent with the existing comment that is present in the code.
Hence it seems reasonable to interpret `transformCode === 0` as no color conversion being necessary.

Fixes the rendering of page 1 in `issue-4926` (from the test-suite), when the built-in `src/core/jpg.js` image decoder is used.
2017-07-11 17:08:30 +02:00
Jonas Jenwald
11e95712d4 Add support for the nativeImageDecoderSupport parameter, to force JPEG image decoding using src/core/jpg.js, when running the reference tests 2017-07-11 16:38:49 +02:00
Nimesh Solanki
e004b3cfab update inconsistent names 2017-07-11 00:57:39 +05:30
Rob Wu
01f03fe393 Optimize PNG compression in SVG backend on Node.js
Use the environment's zlib implementation if available to get
reasonably-sized SVG files when an XObject image is converted to PNG.
The generated PNG is not optimal because we do not use a PNG predictor.
Futher, when our SVG backend is run in a browser, the generated PNG
images will still be unnecessarily large (though the use of blob:-URLs
when available should reduce the impact on memory usage). If we want to
optimize PNG images in browsers too, we can either try to use a DEFLATE
library such as pako, or re-use our XObject image painting logic in
src/display/canvas.js. This potential improvement is not implemented by
this commit

Tested with:

- Node.js 8.1.3 (uses zlib)
- Node.js 0.11.12 (uses zlib)
- Node.js 0.10.48 (falls back to inferior existing implementation).
- Chrome 59.0.3071.86
- Firefox 54.0

Tests:

Unit test on Node.js:

```
$ gulp lib
$ JASMINE_CONFIG_PATH=test/unit/clitests.json node ./node_modules/.bin/jasmine --filter=SVG
```

Unit test in browser: Run `gulp server` and open
http://localhost:8888/test/unit/unit_test.html?spec=SVGGraphics

To verify that the patch works as desired,

```
$ node examples/node/pdf2svg.js test/pdfs/xobject-image.pdf
$ du -b svgdump/xobject-image-1.svg
 # ^ Calculates the file size. Confirm that the size is small
 #   (784 instead of 80664 bytes).
```
2017-07-10 18:56:57 +02:00
Rob Wu
3479a19bf0 Remove btoa from domstubs.js
btoa is already defined by src/shared/compatibility.js,
which is unconditionally imported by src/shared/util.js.
2017-07-10 18:45:47 +02:00
Rob Wu
a488ff4f70 Put every test file on a separate lint in jasmine-boot.js 2017-07-10 18:45:47 +02:00
Rob Wu
9caaaf3a91 Add setStubs/unsetStubs to domstubs to support testing
Do not directly export to global. Instead, export all stubs in domstubs.js and
add a method setStubs to assign all exported stubs to a namespace. Then replace
the import domstubs with an explicit call to this setStubs method.  Also added
unsetStubs for undoing the changes. This is done to allow unit testing of the
SVG backend without namespace pollution.
2017-07-10 18:45:47 +02:00
Rob Wu
94f1dde07d Move DEFLATE logic in convertImgDataToPng
Move the DEFLATE logic in convertImgDataToPng to a separate function.
A later commit will introduce a more efficient deflate algorithm,
and fall back to the existing, naive algorithm if needed.
2017-07-10 18:45:47 +02:00
Yury Delendik
2cef24a2ad Merge pull request #8630 from Rob--W/issue-8622-remove-__pdfjsdev_webpack__
Remove __pdfjsdev_webpack__, use webpack options
2017-07-10 11:31:45 -05:00
Jonas Jenwald
85161fa6dc Update l10n files 2017-07-10 12:20:25 +02:00
Rob Wu
742ed3d1c9 Remove __pdfjsdev_webpack__, use webpack options
`__pdfjsdev_webpack__` was used to skip evaluating part of an AST,
in order to not mangle some `require` symbols.
This commit removes `__pdfjsdev_webpack__`, and:

- Uses `__non_webpack_require__` when one wants the output to
  contain `require` instead of `__webpack_require__`.
- Adds options to the webpack config to prevent "polyfills" for
  some Node.js-specific APIs to be added.
- Use `// eslint-disable-next-line no-undef` instead of `/* globals ... */`
  for variables that are not meant to be used globally.
2017-07-09 16:35:48 +02:00
Yury Delendik
7b4887dd21 Merge pull request #8581 from yurydelendik/rm-error
Removes error()
2017-07-07 09:43:30 -05:00
Yury Delendik
d028c26210 Removes error() 2017-07-07 09:40:24 -05:00
Jonas Jenwald
ac9802809c Merge pull request #8621 from Rob--W/eslint-version-update
Bump minimum eslint version to 3.19.0
2017-07-06 15:58:06 +02:00
Rob Wu
06887b6b62 Bump minimum eslint version to 3.19.0
The previously referenced eslint version is not compatible with our code base.
For example, rule "prefer-promise-reject-errors" requires 3.14.0.
2017-07-06 15:40:08 +02:00
Jonas Jenwald
c253ee9ab8 Ensure that the document is rendered on load, no matter what happens, by always calling PDFViewer.update *after* the initial position has been set 2017-07-06 13:50:02 +02:00
Jonas Jenwald
8391aacb89 Remove the scale-not-initialized hack from webViewerResize (in app.js)
Since we no longer, after PR 8555, allow changing the scale until the document is loaded, that hack is no longer necessary. Furthermore, no part of that event handling function needs to run unless a document is loaded.

The reason that this hack was initially added, is that previously the `ViewHistory` might be updated *before* `PDFViewerApplication.setInitialView` had run (in some cases leading to incorrect inital document scale). Since that is no longer possible, this is now dead code.
2017-07-06 13:13:22 +02:00
Jonas Jenwald
12f1b747b1 Merge pull request #8555 from Snuffleupagus/viewer-components-pdfDocument-checks
Don't allow setting various properties, such as `currentPageNumber`/`currentScale`/`currentScaleValue`/`pagesRotation`, before `{PDFViewer, PDFThumbnailViewer}.setDocument` has been called
2017-07-06 06:30:13 +02:00
Jonas Jenwald
1788a6b0cf Merge pull request #8615 from Snuffleupagus/issue-8613
Fix a stupid spelling error in the `ASCII85Decode` name in `Parser.makeInlineImage` (issue 8613)
2017-07-05 22:22:04 +02:00
Jonas Jenwald
ea71d23f74 Fix a stupid spelling error in the ASCII85Decode name in Parser.makeInlineImage (issue 8613)
This is a trivial follow-up to PR 5383, and it's a bit strange that this has been wrong since late 2014 without anyone noticing (maybe because inline images aren't too common).
So, apparently code works better if you actually spell correctly, who knew ;-)

Fixes 8613.
2017-07-05 19:43:09 +02:00
Yury Delendik
b3bac5100c Merge pull request #8596 from mukulmishra18/proper-read-result
Fixes wrong structure of fullReader.read() result.
2017-07-05 09:03:57 -05:00
Jonas Jenwald
9c95614bb6 Ensure that PDFFindBar._adjustWidth is called in all situations where the width of the findbar might have changed
After PR 8394, where the l10n service was converted to be asynchronous, we're no longer calling `_adjustWidth` after updating the `findMsg` label. Hence it's currently possible that the width of the findbar won't be correct. The solution is simple though, just call `_adjustWidth` after the `findMsg` label has been (asynchronously) updated.

Another existing issue, which was an oversight in PR 8132, is that `PDFFindBar.updateResultsCount` may be called directly from `PDFFindController`. In that case, we're not calling `_adjustWidth` at all, which means that the findbar may also not have the correct width.
The simple solution here is to always call `_adjustWidth` at the end of `updateResultsCount` (which is why we no longer need the `_adjustWidth` call at the end of `updateUIState`).
2017-07-05 11:34:14 +02:00
Jonas Jenwald
cb0009dab4 Actually reset the findResultsCount label, in addition to hiding it, when no matches are found
Currently we're *only* hiding the label, but not actually resetting it until a new match is found.
Obviously it's being hidden, but it seems that it really ought to be completely reset as well (since e.g. `PDFFindBar.reset` won't technically reset *all* state otherwise).
2017-07-05 11:19:29 +02:00
Jonas Jenwald
eff257b820 Merge pull request #8580 from brendandahl/missing-glyf
Fix how we detect and handle missing glyph data.
2017-07-04 12:16:07 +02:00
Jonas Jenwald
05b1ef2d23 Merge pull request #8594 from Snuffleupagus/es6-web-let
Change `var` to `let`, and use object destructuring, in a couple of previously class converted `web/*.js` files
2017-07-04 11:59:25 +02:00
Brendan Dahl
9f5c1550ed Merge pull request #8592 from brendandahl/cmap-3-0
Only mask char codes of (3, 0) cmap tables in the range of 0xF000 to 0…
2017-07-03 17:58:28 -07:00
Brendan Dahl
efbbd8533f Only mask char codes of (3, 0) cmap tables in the range of 0xF000 to 0xF0FF. 2017-07-03 13:13:46 -07:00
Brendan Dahl
6d4f748fb1 Fix how we detect and handle missing glyph data. 2017-07-03 13:06:06 -07:00
Jonas Jenwald
614e8cf295 Change var to let, and use object destructuring, in a couple of previously class converted web/*.js files
Note that these files were among the first to be converted to ES6 classes, so it probably makes sense to do another pass to bring them inline with the most recent ES6 conversions.
2017-07-03 11:22:49 +02:00
Jonas Jenwald
699f3392e4 Update l10n files 2017-07-03 11:10:21 +02:00
Mukul Mishra
308a83e5ca Fixes wrong structure of fullReader.read() result. 2017-07-01 15:52:47 +05:30
Tim van der Meij
9e4dcf156b Merge pull request #8585 from Snuffleupagus/issue-8584
Check that the `MessageHandler` isn't already terminated in the `onFailure` handler in `src/core/worker.js` (issue 8584)
2017-06-30 23:28:59 +02:00
Jonas Jenwald
82bd62ecc6 Merge pull request #8583 from Snuffleupagus/es6-app
ES6-ify the code in `web/app.js` and `web/viewer.js`
2017-06-30 10:19:09 +02:00
Jonas Jenwald
de0e7a9a68 Check that the MessageHandler isn't already terminated in the onFailure handler in src/core/worker.js (issue 8584)
All other code-paths already checks that the `MessageHandler` isn't terminated, but apparently `onFailure` was missing that check (compare e.g. with the `onSuccess` function).
From what I can tell, this is only an issue if workers are *disabled*, hence why I didn't bother adding a unit-test.

Fixes 8584.
2017-06-30 10:11:13 +02:00
Jonas Jenwald
d64ac95a91 ES6-ify the code in web/app.js and web/viewer.js
The changes consist mostly of changing `var` to `let`/`const`, and using shorthand method signatures.
2017-06-30 10:10:01 +02:00
Jonas Jenwald
80c33253ed Merge pull request #8582 from timvandermeij/es6-text-layer-builder
Convert the text layer builder to ES6 syntax
2017-06-30 10:08:28 +02:00
Tim van der Meij
19f56ec5c1
Convert the text layer builder to ES6 syntax 2017-06-29 23:41:25 +02:00
Jonas Jenwald
87a0031d77 Merge pull request #8589 from brendandahl/fix-expert-encoding
Fix missing notdef in expert encoding.
2017-06-29 22:05:44 +02:00
Brendan Dahl
a8a8909d2d Fix missing notdef in expert encoding. 2017-06-29 12:12:39 -07:00
Tim van der Meij
d6a6f390ae Merge pull request #8578 from Snuffleupagus/es6-ui_utils
ES6-ify the code in `web/ui_utils.js`
2017-06-28 22:24:37 +02:00
Jonas Jenwald
f6369fc87c ES6-ify the code in web/ui_utils.js
These changes consists mainly of replacing `var` with `let`/`const`, adding a couple of default parameters to function signatures, and finally converting `EventBus`/`ProgressBar` to proper classes.
2017-06-28 12:35:12 +02:00
Jonas Jenwald
f2fcf2a59c Merge pull request #8574 from timvandermeij/svg-stroke-properties
SVG: move setting the stroke properties to the `stroke` method
2017-06-27 10:16:30 +02:00
Tim van der Meij
f87f0d6812 Merge pull request #8576 from Snuffleupagus/toolbar-inline-selectScaleOption
Remove the `selectScaleOption` helper function, in `Toolbar._updateUIState`, and simply inline its code instead
2017-06-26 23:28:43 +02:00
Jonas Jenwald
1db290e818 Update l10n files 2017-06-26 14:30:41 +02:00
Jonas Jenwald
d4b93bec96 Remove the selectScaleOption helper function, in Toolbar._updateUIState, and simply inline its code instead
After PR 8510, we now always lookup the localized `page_scale_percent` string to prevent any possible ordering issues. Since the scaleSelect dropdown is updated asynchronous, there's really no point in having a helper function any more, hence this code can rather be placed inline in `Toolbar._updateUIState`.
2017-06-26 13:06:24 +02:00
Tim van der Meij
f1a87bab10
SVG: move setting the stroke properties to the stroke method
In general, we may not know the stroke properties when path construction
happens. Since we must know the properties when we apply the stroke, we
should set the properties at that point. Note that we already do that
for the color and opacity, but not yet for the other properties.
2017-06-25 22:28:46 +02:00
Jonas Jenwald
859e3d4dce Merge pull request #8564 from timvandermeij/svg-opacity
SVG: implement fill and stroke opacity
2017-06-24 22:42:18 +02:00
Tim van der Meij
d3a3b1db13 Merge pull request #8571 from Snuffleupagus/readme-es6
Mention in the "Getting the Code" section of README.md that an ES6 compatible browser is required when using the default viewer with `gulp server`
2017-06-24 22:14:29 +02:00
Jonas Jenwald
84d0df2b31 Mention in the "Getting the Code" section of README.md that an ES6 compatible browser is required when using the default viewer with gulp server
The https://github.com/mozilla/pdf.js/wiki/Contributing article has been updated to explicitly mention that an ES6 browser is now a minimum requirement for development.
Since we recently have seen a couple of issues filed which seemed to indicate that people tried to use PDF.js in browsers without full ES6 support, it's probably a good idea to mention this more prominently in the README as well.
2017-06-24 12:36:20 +02:00
Brendan Dahl
f1f9d98519 Merge pull request #8507 from Snuffleupagus/issue-8480
Only special-case OpenType fonts with `CFF` data if it's both a composite (i.e. Type0) font and also has a non-default CID to GID map (issue 8480)
2017-06-23 13:36:58 -07:00