Commit Graph

10235 Commits

Author SHA1 Message Date
Yury Delendik
fab59e0f91 Revert "Closes all promises/streams when handler is destroyed." 2017-10-06 11:55:28 -05:00
Tim van der Meij
460c4e38cc Merge pull request #8994 from Snuffleupagus/PDFHistory-forward
Fix a regression that (effectively) makes `PDFHistory.forward` a no-op
2017-10-05 23:04:46 +02:00
Jonas Jenwald
e3873b29fd Merge pull request #8990 from pixelexel/fix-#8951
Added component example for single page viewer
2017-10-05 20:31:29 +02:00
Brendan Dahl
bc396efb54 Reccomend attaching pdfs instead of links. 2017-10-05 11:29:56 -07:00
pixel
484ec3d09c Added component example for single page viewer
Checking for PDFJS.PDFSinglePageViewer instead

Added component example for single page viewer
2017-10-05 23:46:02 +05:30
Jonas Jenwald
e772124339 Fix a regression that (effectively) makes PDFHistory.forward a no-op
*It appears that this accidentally broken in PR 8775.*

Note that `PDFHistory.forward` is only used with certain named actions, and these aren't that commonly used, which ought to explain why this error managed to sneak in.

Steps to reproduce the issue (and verify the fix):
 1. Navigate to e.g. http://mirrors.ctan.org/info/lshort/english/lshort.pdf
 2. Click on a couple of links, or outline items, such that the history is populated with a few entries.
 3. In the console, execute `PDFViewerApplication.pdfHistory.back()` one or more times, thus navigating back to a previous viewer position.
 4. In the console, execute `PDFViewerApplication.pdfHistory.forward() one or more times.

At the last step above, no (forward) navigation happens with the current `master`; now compare with this patch.
2017-10-05 13:56:40 +02:00
Jonas Jenwald
04d4faefc4 Remove the this._currentUid property from PDFHistory, since it's no longer needed
Commit 938dffb06b, in PR 8885, removed the only actual usage of `this._currentUid` and it can thus be removed.
2017-10-05 13:38:25 +02:00
Tim van der Meij
e279d37181 Merge pull request #8980 from LukasDrgon/patch-1
Add CDN links
2017-10-03 22:51:02 +02:00
Lukas Drgon
c2f1ff48d5 Add CDN link
Add CDN link

Add Popular CDNs

Add popular CDNs (site)

Moving section
2017-10-02 22:14:06 +02:00
Tim van der Meij
ef02d3d8da Merge pull request #8983 from Snuffleupagus/rm-unused
Remove unused helper code
2017-10-02 21:57:21 +02:00
Jonas Jenwald
5b67c7594c Remove the unused Util.sign function from src/shared/util.js
This has been completely unused since commit 10bb6c9ec0, in PR 2505, more than four and a half years ago.
2017-10-01 15:58:03 +02:00
Jonas Jenwald
65352c730f Remove the unused isWorker property from src/display/global.js
This has been completely unused since commit 1d12aed5ca, in PR 7126, almost one and a half years ago.
2017-10-01 15:49:55 +02:00
Tim van der Meij
50b1a91c02 Merge pull request #8981 from timvandermeij/translations
Update translations
2017-10-01 14:45:23 +02:00
Tim van der Meij
9a1f8b864e
Update translations 2017-10-01 14:42:00 +02:00
Tim van der Meij
9742e58275 Merge pull request #8977 from timvandermeij/updates
Update all packages to the most recent version
2017-10-01 14:36:15 +02:00
Jonas Jenwald
f9ce904fb7 Merge pull request #8979 from timvandermeij/downloads
Transform Web Archive URLs to avoid downloading an HTML page instead of the PDF file
2017-09-30 22:47:23 +02:00
Tim van der Meij
f73c9b75d9
Transform Web Archive URLs to avoid downloading an HTML page instead of the PDF file
Moreover, adjust one linked test case that did not conform to the
standard Web Archive URL format and adjust one linked test case because
the link was dead.
2017-09-30 19:50:31 +02:00
Tim van der Meij
0733b54e10
Update all packages to the most recent version
To support this, the following changes have to be made as well:

- Ignore `package-lock.json` since NPM creates it, but we should not
  have it in the repository.
- Switch from `babel-preset-es2015` to `babel-preset-env` to resolve
  the deprecation warning in the test logs. The latter is more recent
  and flexible, but should be the same functionality-wise.
- `transform` now needs to have the `utf-8` encoding option provided.
  If not given, it will call the callback with a `Buffer` object,
  which results in an unhandled promise rejection since what is
  returned from the callback is a string, not a `Buffer`.
2017-09-30 16:26:24 +02:00
Brendan Dahl
d03e127434 Merge pull request #8971 from yurydelendik/close-handler
Closes all promises/streams when handler is destroyed.
2017-09-29 14:28:53 -07:00
Tim van der Meij
3717757b39 Merge pull request #8976 from Snuffleupagus/webpack-simpler-node-polyfills-disable
Simplify the disabling of Node polyfills, in `gulpfile.js`, since we're now using Webpack 3.x
2017-09-29 22:10:57 +02:00
Jonas Jenwald
1a3c6f7d9a Simplify the disabling of Node polyfills, in gulpfile.js, since we're now using Webpack 3.x
Webpack was updated a while back, but we apparently forgot to update `gulpfile.js` as well.
2017-09-29 21:45:14 +02:00
Jonas Jenwald
b3f8411264 Merge pull request #8968 from Snuffleupagus/PDFFunctionFactory-2
Split the existing `PDFFunction` in two classes, a private `PDFFunction` and a public `PDFFunctionFactory``, and utilize the latter in `PDFDocument` to allow various code to access the methods of `PDFFunction`
2017-09-29 16:16:57 +02:00
Jonas Jenwald
b8ec518a1e Split the existing PDFFunction in two classes, a private PDFFunction and a public PDFFunctionFactory, and utilize the latter in PDFDocument to allow various code to access the methods of PDFFunction`
*Follow-up to PR 8909.*

This requires us to pass around `pdfFunctionFactory` to quite a lot of existing code, however I don't see another way of handling this while still guaranteeing that we can access `PDFFunction` as freely as in the old code.

Please note that the patch passes all tests locally (unit, font, reference), and I *very* much hope that we have sufficient test-coverage for the code in question to catch any typos/mistakes in the re-factoring.
2017-09-29 15:30:53 +02:00
Jonas Jenwald
5c961c76bb Remove the unused inline parameter from various methods/functions in PDFImage, and change a couple of methods to use Objects rather than plain parameters
The `inline` parameter is passed to a number of methods/functions in `PDFImage`, despite not actually being used. Its value is never checked, nor is it ever assigned to the current `PDFImage` instance (i.e. no `this.inline = inline` exists).
Looking briefly at the history of this code, I was also unable to find a point in time where `inline` was being used.

As far as I'm concerned, `inline` does nothing more than add clutter to already very unwieldy method/function signatures, hence why I'm proposing that we just remove it.
To further simplify call-sites using `PDFImage`/`NativeImageDecoder`, a number of methods/functions are changed to take Objects rather than a bunch of (somewhat) randomly ordered parameters.
2017-09-29 15:30:40 +02:00
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
Yury Delendik
71b0e4e818 Closes all promises/streams when handler is destroyed. 2017-09-28 16:45:04 -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