Commit Graph

9919 Commits

Author SHA1 Message Date
Jonas Jenwald
699f3392e4 Update l10n files 2017-07-03 11:10:21 +02:00
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
Yury Delendik
e2ca894fec Merge pull request #8488 from mukulmishra18/streams-getTextContent
Streams get text content
2017-06-23 12:52:13 -05:00
Yury Delendik
d1567a947e Merge pull request #8567 from ghetolay/fix_CMapReaderFactory+worker
Fix error when using custom CMapReaderFactory
2017-06-23 12:49:55 -05:00
ghetolay
7f79e12383 Fix error when using custom CMapReaderFactory and worker 2017-06-23 15:59:43 +02:00
Tim van der Meij
f9eafefa09
SVG: implement stroke opacity 2017-06-23 00:37:27 +02:00
Tim van der Meij
440914e49b
SVG: implement fill opacity
This makes the `eoFill` method similar to the `eoStroke` method and the
ones in `src/display/canvas.js`.
2017-06-23 00:37:27 +02:00
Tim van der Meij
2f2e539bc6 Merge pull request #8561 from Snuffleupagus/zoomLayer-canvas-hidden
Don't use a hidden canvas when constructing the `zoomLayer` in `PDFPageView.update`
2017-06-22 23:51:21 +02:00
Tim van der Meij
c6ee05f7e5 Merge pull request #8542 from Rob--W/svg-clipping
Move svg:clipPath generation from clip to endPath
2017-06-22 23:48:06 +02:00
Jonas Jenwald
426e26c63b Don't use a hidden canvas when constructing the zoomLayer in PDFPageView.update
*This is an existing issue that I noticed while testing PR 8552.*

When zooming or rotation occurs, we'll try to use the current canvas as a (CSS transformed) preview until the page has been completely re-drawn.
If you manage to change the scale (or rotation) *very* quickly, it's possible that `PDFPageView.update` can be called *before* a previous `render` operation has progressed far enough to remove the `hidden` property from the canvas.

The result is thus that a page may be *entirely* black during zooming or rotation, which doesn't look very good. This effect can be a bit difficult to spot, but it does manifest even in the default viewer.
2017-06-22 10:05:41 +02:00
Rob Wu
fc6448d18c Move svg:clipPath generation from clip to endPath
In the PDF from issue 8527, the clip operator (W) shows up before a path
is defined. The current SVG backend however expects a path to exist
before generating a `<svg:clipPath>` element.
In the example, the path was defined after the clip, followed by a
endPath operator (n).
So this commit fixes the bug by moving the path generation logic from
clip to endPath.

Our canvas backend appears to use similar logic:
`CanvasGraphics_endPath` calls `consumePath`, which in turn draws the
clip and resets the `pendingClip` state. The canvas backend calls
`consumePath` from multiple other places, so we probably need to check
whether doing so is also necessary for the SVG backend.

I scanned our corpus of PDF files in test/pdfs, and found that in every
instance (except for one), the "W" PDF operator (clip) is immediately
followed by "n" (endPath). The new test from this commit (clippath.pdf)
starts with "W", followed by a path definition and then "n".

    # Commands used to find some of the clipping commands:
    grep -ra '^W$' -C7 | less -S
    grep -ra '^W ' -C7 | less -S
    grep -ra ' W$' -C7 | less -S

test/pdfs/issue6413.pdf is the only file where "W" (a tline 55) is not
followed by "n". In fact, the "W" is the last operation of a series of
XObject painting operations, and removing it does not have any effect
on the rendered PDF (confirmed by looking at the output of PDF.js's
canvas backend, and ImageMagick's convert command).
2017-06-22 01:08:17 +02:00
Tim van der Meij
36fb3686cc Merge pull request #8556 from Snuffleupagus/app-remove-pageRotation
Stop tracking the rotation in `PDFViewerApplication` and directly use `PDFViewer.pagesRotation` instead
2017-06-22 00:03:58 +02:00
Jonas Jenwald
5ff4cd8f0d Merge pull request #8552 from yurydelendik/canvas-hidden
Ensure canvas is really hidden when used with pdfjs-dist.
2017-06-21 17:28:45 +02:00
Jonas Jenwald
83673a12d7 Stop tracking the rotation in PDFViewerApplication and directly use PDFViewer.pagesRotation instead
Part of the rotation handling code, in what's now `web/app.js`, hasn't really changed since before the viewer was split into multiple files/components.

Similar to other properties, such as current page/scale, we should probably avoid tracking state in multiple places. Hence I'm suggesting that we don't store the rotation in `PDFViewerApplication`, and access the value in `PDFViewer` instead.

Since `PDFViewerApplication.pageRotation` has existed for a very long time, a getter was added to avoid outright breaking third-party code that may depend on it.
2017-06-21 11:45:36 +02:00
Yury Delendik
9bed695ebd Merge pull request #8540 from Rob--W/svg-oom
Reduce memory requirements of pdf2svg.js example to avoid OOM
2017-06-20 17:24:48 -05:00
Yury Delendik
18e1f3d29b Ensure canvas is really hidden when used with pdfjs-dist.
Avoids black background flickering in such examples as components/simpleviewer.html
2017-06-20 14:45:07 -05:00
Jonas Jenwald
054fe13920 Merge pull request #8537 from timvandermeij/es6-toolbar
Convert the toolbar to ES6 syntax
2017-06-20 10:19:06 +02:00
Rob Wu
0cc1735809 Reduce concurrent memory footprint of pdf2svg.js
Wait for the completion of writing the generated SVG file before
processing the next page. This is to enable the garbage collector to
garbage-collect the (potentially large) SVG string before trying to
allocate memory again for the next page.

Note that since the PDF-to-SVG conversion is now sequential instead of
parallel, the time to generate all pages increases.

Test case:
node --max_old_space_size=200 examples/node/pdf2svg.js /tmp/FatalProcessOutOfMemory.pdf

Before this patch:
- Node.js crashes due to OOM after processing 20 pages.

After this patch:
- Node.js is able to convert all 203 PDFs to SVG without crashing.
2017-06-19 21:53:11 +02:00
Rob Wu
849d8cfa24 Improve memory-efficiency of DOMElement_toString in domstubs
Test case:
Using the PDF file from https://github.com/mozilla/pdf.js/issues/8534
node --max_old_space_size=200 examples/node/pdf2svg.js /tmp/FatalProcessOutOfMemory.pdf

Before this patch:
Node.js crashes due to OOM after processing 10 pages.

After this patch:
Node.js crashes due to OOM after processing 19 pages.
2017-06-19 21:52:39 +02:00
Yury Delendik
679ffc84f6 Merge pull request #8544 from Rob--W/compatiblity-safari-strict-error
compatibility.js: Rename parameters in JURL
2017-06-19 10:34:33 -05:00
Rob Wu
f912f89e69 compatibility.js: Rename parameters in JURL 2017-06-19 17:03:41 +02:00
Yury Delendik
df4782dab7 Merge pull request #8543 from Rob--W/svg-domstubs-closePath
Add getAttributeNS to domstubs for SVG example
2017-06-19 09:58:18 -05:00
Rob Wu
4f22ba54bf Add getAttributeNS to domstubs for SVG example
The closePath method in src/display/svg.js relies on this.
2017-06-19 14:11:13 +02:00
Jonas Jenwald
b0bf69dd8c Update l10n files 2017-06-19 11:37:18 +02:00
Tim van der Meij
d4e0aa4031
Convert the toolbar to ES6 syntax 2017-06-18 22:20:13 +02:00
Tim van der Meij
db52e4fb73 Merge pull request #8536 from Snuffleupagus/refactor-ObjectLoader
Refactor `ObjectLoader` to use `Dict`s correctly, rather than abusing their internal properties
2017-06-18 22:17:40 +02:00
Tim van der Meij
a6311471a7 Merge pull request #8539 from Snuffleupagus/rm-load-currentScale-call
Remove a redundant `PDFViewer.currentScale` call from `PDFViewerApplication.load`
2017-06-18 22:00:39 +02:00
Jonas Jenwald
4aab3cef4a Remove a redundant PDFViewer.currentScale call from PDFViewerApplication.load
Since this call occurs *before* the `PDFViewer.setDocument` call, it won't actually cause any scale change.
Furthermore, moving it should not be necessary, since the `scale` is already used as the fallback case in `PDFViewerApplication.setInitialView` (provided it's non-zero, which isn't even the case in the default viewer).

Hence this patch should cause no functional changes at all, since it simply removes a piece of unnecessary code.
2017-06-18 14:34:29 +02:00
Tim van der Meij
8e9b4b5ff2 Merge pull request #8535 from Snuffleupagus/app-close-pageRotation-downloadComplete
Reset `pageRotation` and `downloadComplete` in `PDFViewerApplication.close`
2017-06-17 22:36:42 +02:00
Tim van der Meij
7215e9c52e Merge pull request #8525 from curiosity26/master
Allow for unbinding of events in web application
2017-06-17 22:32:16 +02:00
Jonas Jenwald
73234577e1 Rename map to _map inside of Dict, to make it clearer that it should be regarded as a "private" property 2017-06-17 17:32:00 +02:00
Mukul Mishra
0c13d0ff46 Adds Streams API in getTextContent to stream data.
This patch adds Streams API support in getTextContent
so that we can stream data in chunks instead of fetching
whole data from worker thread to main thread. This patch
supports Streams API without changing the core functionality
of getTextContent.

Enqueue textContent directly at getTextContent in partialEvaluator.

Adds desiredSize and ready property in streamSink.
2017-06-17 20:03:27 +05:30