Commit Graph

10210 Commits

Author SHA1 Message Date
Yury Delendik
f206ee56bf Merge pull request #8962 from Snuffleupagus/CMapReaderFactory-baseUrl-check
Check that `this.baseUrl` is defined before attempting to fetch any data in `DOMCMapReaderFactory`/`NodeCMapReaderFactory`
2017-09-29 07:50:57 -05:00
Jonas Jenwald
a159c4f357 Check that this.baseUrl is defined before attempting to fetch any data in DOMCMapReaderFactory/NodeCMapReaderFactory 2017-09-28 12:34:57 +02:00
Jonas Jenwald
25806d17f4 Merge pull request #8959 from Snuffleupagus/api-worker-version-check
Ensure that the same exact version of PDF.js is used in both the API and the Worker
2017-09-27 18:51:57 +02:00
Jonas Jenwald
7d3efe43a2 Ensure that the same exact version of PDF.js is used in both the API and the Worker
I don't have a good example at hand right know, but I recall seeing custom deployments of PDF.js that bundle a *specific* version of the `build/pdf.js` file and then set `PDFJS.workerSrc` to point to https://mozilla.github.io/pdf.js/build/pdf.worker.js.
That practice seems really bad since, besides (obviously) causing unnecessary server load, it will very quickly result in a version mismatch between the `pdf.js` and `pdf.worker.js` files in those PDF.js deployments.
Such a version mismatch could easily lead to either breaking errors, or even worse slightly inconsistent behaviour for an API call (if the API -> Worker interface changes, which does happen from time to time).

To avoid the problems described above, I'm thus proposing that we enforce that the versions of the `pdf.js` and `pdf.worker.js` files must always match.
2017-09-27 15:41:57 +02:00
Jonas Jenwald
b837187094 Merge pull request #8955 from brendandahl/issue7507
Overwrite maxSizeOfInstructions in maxp with computed value.
2017-09-26 14:16:56 +02:00
Brendan Dahl
18e2321845 Overwrite maxSizeOfInstructions in maxp with computed value.
In issue #7507 the value is less than the actuall max size
of the glyph instructions causing OTS to fail the font.
2017-09-25 17:53:26 -07:00
Jonas Jenwald
a1f5c26f54 Update l10n files 2017-09-25 09:39:21 +02:00
Tim van der Meij
f3987bba23 Merge pull request #8724 from Snuffleupagus/PDFSinglePageViewer
Implement a `PDFSinglePageViewer` class (issue 8188)
2017-09-24 19:41:37 +02:00
Jonas Jenwald
10727572a2 Merge pull request #8950 from timvandermeij/polygon-polyline-annotations
Implement support for polyline and polygon annotations
2017-09-24 15:16:14 +02:00
Tim van der Meij
c69a7a83da Merge pull request #8932 from janpe2/jbig2-sym-offset
JBIG2 symbol offsets
2017-09-23 17:11:45 +02:00
Tim van der Meij
ed8c0ebfa7
Implement reference tests for polyline and polygon annotations 2017-09-23 17:01:19 +02:00
Tim van der Meij
8ccad276b2
Implement support for polygon annotations 2017-09-23 16:52:47 +02:00
Tim van der Meij
99b17a494d
Implement support for polyline annotations 2017-09-23 16:37:23 +02:00
Jonas Jenwald
23daafd728 Implement a PDFSinglePageViewer class (issue 8188)
The new `PDFSinglePageViewer` class extends the previously created abstract `BaseViewer` class.

There's *a lot* of existing functionality in `PDFViewer` that depends on all the pages being loaded and synchronously available, once the `setDocument` method has been called.
Given that initializing `PDFPageView` instances requires passing a DOM element to which the page is attached, the simplest solution I could come up with is to append all pages to a (hidden) document fragment and just swap them (one at a time) into the viewer when page switching occurs.
2017-09-23 16:28:04 +02:00
Jonas Jenwald
5fa9cca8dd Refactor PDFViewer to extend an abstract BaseViewer class
This patch introduces an abstract `BaseViewer` class, that the existing `PDFViewer` then extends. *Please note:* This lays the necessary foundation for the next patch.
2017-09-23 16:28:04 +02:00
Jonas Jenwald
d7198d3e17 Rename web/pdf_viewer.js to web/base_viewer.js
Please note that the only reason for this change is to try and improve reviewability of later patches, by keeping the diffs more manageable.
2017-09-23 16:28:04 +02:00
Tim van der Meij
40b89e9ba4 Merge pull request #8949 from Snuffleupagus/ColorSpace-rm-instanceof-AlternateCS
Remove the `instanceof AlternateCS` check in `ColorSpace.parse` since it's dead code
2017-09-23 16:09:17 +02:00
Tim van der Meij
2aac994171 Merge pull request #8928 from mukulmishra18/decode-file-path
Fix #8907: Decode URL to get correct path in node_stream.
2017-09-23 14:44:58 +02:00
Jonas Jenwald
8a084aff0f Remove the instanceof AlternateCS check in ColorSpace.parse since it's dead code
Looking at `ColorSpace.parseToIR`, it will do one of the following things when called:
 1. Return a String.
 2. Return an Array.
 3. Throw a `FormatError`.
 4. In one case, return the result of *another* `ColorSpace.parseToIR` call.

However, under no circumstances will it ever return an `AlternateCS` instance.

Since it's often useful to understand why code, which has become unused, existed in the first place, let's grab a hard hat and a shovel and start digging through the history of this code :-)

The current condition was introduced in commit c198ec4323, in PR 794, but it was actually already obsolete by that time.
The preceeding `instanceof SeparationCS` condition predates commit a7278b7fbc, in PR 700.
That condition was originally introduced all the way back in commit 4e3f87b60c, in PR 692. However, it was made obsolete by commit 9dcefe1efc, which is included in the very same PR!

Hence we're left with the conclusion that not only has this code be unused for *almost* six years, it was basically never used at all save for a few refactoring commits that're part of PR 692.
2017-09-23 14:36:10 +02:00
Tim van der Meij
d7b37ae745 Merge pull request #8912 from timvandermeij/xml-parser
[api-minor] Replace `DOMParser` with `SimpleXMLParser`
2017-09-20 23:45:00 +02:00
Jonas Jenwald
abc864fca9 Merge pull request #8938 from brendandahl/bug1392647
Use font's default width even when 0. (bug 1392647)
2017-09-20 22:38:39 +02:00
Brendan Dahl
10ba292b46 Use font's default width even when 0.
Bug 1392647 has a PDF where the default width of the font
is 0. It draws some charcodes that don't have glyphs, but
we were wrongly using the 1000 default width for these
charcodes causing some text to be overlapping.
2017-09-20 11:38:30 -07:00
Tim van der Meij
2281061882
Enable metadata unit tests for Travis CI and Node.js 2017-09-19 23:09:07 +02:00
Tim van der Meij
d4309614f9
Replace DOMParser with SimpleXMLParser
The `DOMParser` is most likely overkill and may be less secure.
Moreover, it is not supported in Node.js environments.

This patch replaces the `DOMParser` with a simple XML parser. This
should be faster and gives us Node.js support for free. The simple XML
parser is a port of the one that existed in the examples folder with a
small regex fix to make the parsing work correctly.

The unit tests are extended for increased test coverage of the metadata
code. The new method `getAll` is provided so the example does not have
to access internal properties of the object anymore.
2017-09-19 23:09:07 +02:00
Jani Pehkonen
5d1074c110 Fix JBIG2 symbol offsets in text regions 2017-09-19 23:43:23 +03:00
Jonas Jenwald
fbd6e47aaf Merge pull request #8901 from janpe2/ccitt-eofb-false
CCITTFaxStream problem when EndOfBlock is false
2017-09-19 22:23:15 +02:00
Tim van der Meij
bc9afdf3c4
Convert src/display/metadata.js to ES6 syntax 2017-09-19 22:13:59 +02:00
Jani Pehkonen
3d99b8d706 CCITTFaxStream problem when EndOfBlock is false 2017-09-19 22:19:40 +03:00
Mukul Mishra
e4c09c7cba Fix #8907: Decode URL to get correct path in node_stream. 2017-09-19 15:10:36 +05:30
Tim van der Meij
9c2e9dae26 Merge pull request #8921 from THausherr/patch-2
support tiff predictor for 16bit
2017-09-18 23:01:33 +02:00
Tilman Hausherr
d75a497a6b support tiff predictor for 16bit
(for issue #6289)
This does the same for 16 bit as the existing 8 bit tiff predictor code, an addition of the last word to this word.

The last two "& 0xFF" may or may not be needed, I see this isn't done in the 8 bit code, but I'm not a JS developer.
2017-09-18 22:24:25 +02:00
Jonas Jenwald
50bd4a5ac0 Update l10n files 2017-09-18 10:59:44 +02:00
Tim van der Meij
c84c23c4cb Merge pull request #8919 from Snuffleupagus/issue-8915
Ignore 'change' events that didn't originate in the viewer (issue 8915)
2017-09-17 15:21:53 +02:00
Jonas Jenwald
6c3856c841 Ignore 'change' events that didn't originate in the viewer (issue 8915)
Rather that registering a 'change' event listener on the `window`, which will thus (unnecessarily) fire in *a number* of other situations such as e.g. when the user changes the pageNumber or the current search term, we could/should just register it directly on the dynamically created `fileInput` DOM element instead.
I can see no really compelling reason why we actually need to listen for `file` changes on the `window` itself, and this way we're also able to keep the `fileInput` related code confined to one part of the code which should aid readability.
Furthermore, in custom deployments, there's less risk that we're going to interfere with "outside" code this way.

Finally, preprocessor guards were added to the `webViewerOpenFile` function, since that code doesn't make sense in e.g. the extension builds.
2017-09-17 11:34:21 +02:00
Jonas Jenwald
f01f0fdaa7 Merge pull request #8917 from timvandermeij/stamp-annotations
Implement support for stamp annotations
2017-09-17 10:19:14 +02:00
Tim van der Meij
400e4aae0e
Implement support for stamp annotations 2017-09-16 16:37:50 +02:00
Tim van der Meij
3be941d982 Merge pull request #8909 from Snuffleupagus/PDFFunction-isEvalSupported
Check `isEvalSupported`, and test that `eval` is actually supported, before attempting to use the `PostScriptCompiler` (issue 5573)
2017-09-16 16:11:03 +02:00
Tim van der Meij
27773f14d1 Merge pull request #8913 from Snuffleupagus/issue-8895
For /Filter entries containing `Name`s, ignore the /DecodeParms entry if it contains an Array (issue 8895)
2017-09-16 15:43:33 +02:00
Jonas Jenwald
eece66fa3e For /Filter entries containing Names, ignore the /DecodeParms entry if it contains an Array (issue 8895) 2017-09-15 23:02:16 +02:00
Jonas Jenwald
dc926ffc0f Check isEvalSupported, and test that eval is actually supported, before attempting to use the PostScriptCompiler (issue 5573)
Currently `PDFFunction` is implemented (basically) like a class with only `static` methods. Since it's used directly in a number of different `src/core/` files, attempting to pass in `isEvalSupported` would result in code that's *very* messy, not to mention difficult to maintain (since *every* single `PDFFunction` method call would need to include a `isEvalSupported` argument).

Rather than having to wait for a possible re-factoring of `PDFFunction` that would avoid the above problems by design, it probably makes sense to at least set `isEvalSupported` globally for `PDFFunction`.

Please note that there's one caveat with this solution: If `PDFJS.getDocument` is used to open multiple files simultaneously, with *different* `PDFJS.isEvalSupported` values set before each call, then the last one will always win.
However, that seems like enough of an edge-case that we shouldn't have to worry about it. Besides, since we'll also test that `eval` is actually supported, it should be fine.

Fixes 5573.
2017-09-15 12:02:45 +02:00
Yury Delendik
d0d7046129 Merge pull request #8910 from mukulmishra18/include-credentials
Fix #8888: Change behaviour of fetch to make it compatible with XHR.
2017-09-14 14:29:59 -05:00
Mukul Mishra
ef7038fe34 Fix #8888: Change behaviour of fetch to make it compatible with XHR. 2017-09-14 23:53:06 +05:30
Tim van der Meij
31a34335a0 Merge pull request #8900 from Snuffleupagus/ref-test-SimpleLinkService
Use the `SimpleLinkService` when running "annotations" reference tests
2017-09-13 22:25:38 +02:00
Yury Delendik
25c49de048 Merge pull request #8904 from timvandermeij/svg-setattribute-stub
Provide a stub for `setAttribute` in order to use the SVG back-end with Node.js
2017-09-13 07:47:47 -05:00
Tim van der Meij
cc654fd38d
Provide a stub for setAttribute in order to use the SVG back-end with
Node.js

This patch fixes a regression from PR #8691 where we switched to using
`setAttribute` instead of `setAttributeNS` if no namespace is provided.
2017-09-12 23:23:41 +02:00
Jonas Jenwald
1ebbdc253a Use the SimpleLinkService when running "annotations" reference tests
Rather than (basically) duplicating the `SimpleLinkService` in `test/driver.js`, with potential test failuires if you forget to update the test mock, it seems much nicer to just re-use the viewer component.

Note that `SimpleLinkService` is already bundled into the `build/components/pdf_viewer.js` file. Hence we only need to expose it similar to the other viewer components in that file, and make sure that the `gulp components` command runs as part of the test-setup.
2017-09-12 15:24:46 +02:00
Jonas Jenwald
f2618eb2e4 Merge pull request #8808 from janpe2/issue8741
Fix color of image masks inside uncolored patterns
2017-09-12 14:27:56 +02:00
Jonas Jenwald
2916ed080d Merge pull request #8893 from timvandermeij/annotations-css-dedup
Combine the common styles and overrides for the annotation layer reference tests
2017-09-12 13:22:59 +02:00
Jonas Jenwald
ba21996576 Update l10n files 2017-09-11 11:43:12 +02:00
Tim van der Meij
23cbe294d5
Combine the common styles and overrides for the annotation layer
reference tests

This patch allows us to use the common styles as used by the viewer as a
baseline for the annotation layer reference tests. They are extended
with a small set of overrides to ensure that all elements are visible
during the test.

The overrides file now only contains the absolutely necessary rules to
make all elements visible and is therefore no longer an almost verbatim
copy of the common styles.
2017-09-10 18:18:56 +02:00