Commit Graph

1858 Commits

Author SHA1 Message Date
Jonas Jenwald
6606540fe4 Fix errors reported by the func-call-spacing ESLint rule
http://eslint.org/docs/rules/func-call-spacing
2016-12-12 20:35:54 +01:00
Jonas Jenwald
ad915f8af1 Fix errors reported by the comma-spacing ESLint rule
http://eslint.org/docs/rules/comma-spacing
2016-12-12 20:35:53 +01:00
Jonas Jenwald
e53ab844cc Fix errors reported by the no-useless-concat ESLint rule
http://eslint.org/docs/rules/no-useless-concat
2016-12-12 20:35:51 +01:00
Jonas Jenwald
3820946301 Fix (most) errors reported by the no-multi-spaces ESLint rule
http://eslint.org/docs/rules/no-multi-spaces
2016-12-12 20:35:51 +01:00
Jonas Jenwald
9be3aee9c9 Add a parameter to Page_getInheritedPageProp to make it possible to fetch (and dereference) Arrays, and use that for the MediaBox/CropBox getters (issue 7872) 2016-12-08 22:03:42 +01:00
Jonas Jenwald
e386af7b22 Adjust one of the Page Label unit-tests to use a PDF file where the "St" entry is both present and non-default (i.e. greater than one)
I just realized that none of our current unit-tests cover this particular part of the Page Label parsing code, hence this patch adjusts an existing test PDF to include a "St" entry in the Page Label dictionary.
2016-12-04 13:03:22 +01:00
Tim van der Meij
46d2c892de Merge pull request #7857 from jabiinfante/murmurhash3-unit-tests
add basic unit-tests for murmurhash3.js
2016-12-01 16:34:04 +01:00
Javier Infante
54fab606ee add basic unit-tests for murmurhash3.js 2016-12-01 02:21:05 +01:00
Jonas Jenwald
c5b06cb40d Ensure that PartialEvaluator_extractWidths is able to handle indirect objects in all kinds of "width" data (issue 7855)
Fixes 7855.
2016-11-29 20:49:07 +01:00
Jonas Jenwald
451956c0b1 Merge pull request #7628 from Snuffleupagus/issue-7580
Fallback to the `StandardEncoding` for Nonsymbolic fonts without `/Encoding` entry (issue 7580)
2016-11-29 12:37:36 +01:00
Jonas Jenwald
013f69e65f Merge pull request #7700 from Snuffleupagus/non-embedded-NuptialScript
Improve rendering of non-embedded NuptialScript font
2016-11-29 11:00:21 +01:00
Tim van der Meij
9ff19985c0 Merge pull request #7832 from seanburke-wf/expose-userunit-on-page
Expose the optional UserUnit entry as a page property
2016-11-22 21:18:57 +01:00
Jonas Jenwald
3170a4c40a Improve rendering of non-embedded NuptialScript font
*This patch fixes something that I noticed while debugging https://bugzilla.mozilla.org/show_bug.cgi?id=1308536.*

The PDF file contains a font called "NuptialScript", which unfortunately is not embedded. Since that is a non-standard font we will not be able to render it entirely correct. However, by adding "NuptialScript" to the `getNonStdFontMap`, we can at least improve the rendering slightly by using an italic (serif) fallback font.
2016-11-22 17:56:17 +01:00
Sean Burke
f76cd2ce43 Expose the optional UserUnit entry as a page property 2016-11-22 09:18:19 -07:00
Jonas Jenwald
d3043167de Correctly detect more cases of non-embedded Arial Black fonts (issue 7835)
This patch adds support for non-embedded Arial Black fonts, that use a `Arial-Black...` format for the font names.
Also, this patch changes `canvas.js` such that we always render Arial Black fonts with the maximum weight, which actually improves a number of existing test-cases. This should thus explain the test "failures", which are clear improvements compared with e.g. Adobe Reader.

Fixes 7835.
2016-11-22 13:56:21 +01:00
Jonas Jenwald
6d8a404a9c [api-minor] Add support for a couple of white-listed JavaScript actions that contains valid URLs (issue 3897, bug 843699)
By only allowing very specific type of `JavaScript` actions, and also utilizing the existing `URL` validation, this patch shouldn't pose too much risk.

Fixes one of the points in issue 3897 (with the PDF file taken from issue 3438).
Fixes https://bugzilla.mozilla.org/show_bug.cgi?id=843699 (probably, since that bug doesn't contain a test-case).
2016-11-08 16:48:27 +01:00
Jonas Jenwald
b4100ba651 Merge pull request #7698 from Snuffleupagus/bug-1308536
Ignore reserved commands when parsing operands in `CFFParser_parseDict`, instead of just rejecting the entire font (bug 1308536)
2016-11-03 23:53:14 +01:00
Jonas Jenwald
2d8d8b5e53 Use stringToPDFString to sanitizing bad "Prefix" entries in Page Label dictionaries
It seems that certain bad PDF generators can create badly encoded "Prefix" entries for Page Labels, one example being http://ukjewishfilm.org/wp-content/uploads/2015/09/Jewish-Film-Festival-Programme-ONLINE.pdf.

Unfortunately I didn't come across such a PDF file while adding the API support for Page Labels, but with them now being used in the viewer I just found this issue. With this patch, we now display the Page Labels in the same way as Adobe Reader.
2016-11-03 19:48:08 +01:00
Jonas Jenwald
9dc6463933 Ignore reserved commands when parsing operands in CFFParser_parseDict, instead of just rejecting the entire font (bug 1308536)
According to the CFF specification, see http://partners.adobe.com/public/developer/en/font/5176.CFF.pdf#page=11, certain commands are currently reserved.

Fixes https://bugzilla.mozilla.org/show_bug.cgi?id=1308536.
2016-11-03 12:50:40 +01:00
Tim van der Meij
9f8d67475e Merge pull request #7775 from timvandermeij/widget-annotation-name
Widget annotation: implement field name according to the specification
2016-11-02 22:43:17 +01:00
Tim van der Meij
1d96854019 Widget annotation: implement field name according to the specification
The original code is difficult to read and, more importantly, performs
actions that are not described in the specification. It replaces empty
names with a backtick and an index, but this behavior is not described
in the specification. While the specification is not entirely clear
about what should happen in this case, it does specify that the `T`
field is optional and that multiple field dictionaries may have the same
fully qualified name, so to achieve this it makes the most sense to
ignore missing `T` fields during construction of the field name. This is
the most specification-compliant solution and, judging by opened issue #6623, also the required and expected behavior.
2016-11-02 21:44:44 +01:00
Tim van der Meij
6e22b32372 Merge pull request #7745 from Snuffleupagus/Launch-actions
[api-minor] Add basic support for `Launch` actions (issue 1778, issue 3897, issue 6616)
2016-11-01 21:12:08 +01:00
Tim van der Meij
5194e68134 Lint: correct code style violations
Manual observations and working with other linting tools found these.
2016-11-01 15:04:21 +01:00
Jonas Jenwald
2b79782377 [api-minor] Add basic support for Launch actions (issue 1778, issue 3897, issue 6616)
In general we neither want, nor can, support arbitrary `Launch` actions. But in practice, all the cases we've seen so far just contains relative URLs to other PDF files. Building on PR 7689, we can thus at least support basic `Launch` actions.
2016-10-21 13:40:32 +02:00
Jonas Jenwald
d284cfd5eb [api-minor] Add support for relative URLs, in both annotations and the outline, by adding a docBaseUrl parameter to PDFJS.getDocument (bug 766086)
Note that in `FIREFOX/MOZCENTRAL/CHROME` builds of the standard viewer the `docBaseUrl` parameter will be set by default, since in that case it makes sense to use the current URL as a base.
For the `GENERIC` viewer, or the API itself, it doesn't make sense to try and set the `docBaseUrl` by default. However, custom deployments/implementations may still find the parameter useful.
2016-10-19 22:20:24 +02:00
Jonas Jenwald
42f07c6262 [api-minor] Use the new URL constructor when validating URLs in annotations and the outline, as a complement to only checking the protocol, and add a bit more validation to Catalog_parseDestDictionary
Note that this will automatically reject any relative URL.
To make the API more useful to consumers, URLs that are rejected will be available via the `unsafeUrl` property in the data object returned by `PDFPageProxy_getAnnotations`.

The patch also adds a bit more validation of the data for `Named` actions.
2016-10-19 22:11:17 +02:00
Jonas Jenwald
e64bc1fd13 Move parsing of destination dictionaries to a helper function
This not only reduces code duplication, but it also allow us to easily support the same kind of URLs we currently do for Link annotations in the Outline as well.
2016-10-18 16:14:07 +02:00
Yury Delendik
ea5949f1fd Merge pull request #7668 from Snuffleupagus/issue-7665
Prevent an infinite loop in `XRef_fetchUncompressed` for encrypted PDF files with indirect objects in the /Encrypt dictionary (issue 7665)
2016-10-15 10:52:08 -05:00
Chas Emerick
85c52f1fd6 Fix getTextContent evaluation to only apply TJ horizontal offsets using numeric items/args
While the array argument to TJ should only contain strings and numbers, other
unfortunate items are found in PDFs in the wild, e.g.:

[(Grandes) 0.0 Tc
-250.0 (Client\350les,) 0.0 Tc
-250.0 (Financements) 0.0 Tc
-250.0 (et) 0.0 Tc
-250.0 (March\351s) ] TJ

getOperatorList already properly ignores any non-string, non-numeric values in
TJ arrays; without this patch to getTextContent, returned text items can have
NaN widths due to calculations being applied to those non-numeric values.
2016-10-13 08:08:31 -04:00
Tim van der Meij
9b3a91f365 Merge pull request #7671 from timvandermeij/interactive-forms-choice-fields
Interactive forms: render choice widget annotations
2016-10-05 23:27:45 +02:00
Tim van der Meij
f85f3243b1 Choice widget annotations: unit and reference testing 2016-10-05 21:25:29 +02:00
Yury Delendik
7b2a9ee4e0 Merge pull request #7670 from Snuffleupagus/Parser_makeFilter-maybeLength
Only skip parsing a stream in `Parser_makeFilter` when we know for sure that it is empty (PR 6372 follow-up)
2016-10-05 10:38:12 -05:00
Jonas Jenwald
93830032ac Add a unit-test for annotations where the URI action has an incorrect encoding (bug 1122280, PR 5999) 2016-09-30 11:44:24 +02:00
Jonas Jenwald
54ee83eb12 Attempt to skip zero bytes at the end of Scan blocks when decoding JPEG images (issue 4090) 2016-09-28 16:31:02 +02:00
Jonas Jenwald
116ba19dd9 Respect the 'ColorTransform' entry in the image dictionary when decoding JPEG images (bug 956965, issue 6574)
Fixes https://bugzilla.mozilla.org/show_bug.cgi?id=956965.
Fixes 6574.
2016-09-26 21:55:43 +02:00
Jonas Jenwald
a22f0ae820 Only skip parsing a stream in Parser_makeFilter when we know for sure that it is empty (PR 6372 follow-up)
For PDF files with multiple `/Filter`s, where the `/Length` entry is zero, we fail to render the file correctly. The reason is that `maybeLength` is `null` for the every filter except the first, and `!maybeLength` is thus truthy.
Hence it seems that we should completely ignore the `/Length` entry and also explicitly check `maybeLength === 0`.

Note that I've not (yet) come across a PDF file with this issue in the wild, but given all the stupid things PDF generators do I wouldn't be surprised if such a file actually exists. In order to prevent a possible future bug, I'm submitting this patch which includes a hand-edited PDF file that we currently cannot render correctly (but e.g. Adobe Reader can).
2016-09-25 12:40:15 +02:00
Jonas Jenwald
4d2de9b47e Add a reduced load test for issue 7665 2016-09-25 00:19:42 +02:00
Jonas Jenwald
6c263c1994 Merge pull request #7649 from timvandermeij/interactive-forms-tx-comb
Text widget annotations: implement comb support
2016-09-22 11:36:30 +02:00
Tim van der Meij
375229d6b9 Widget annotations: simplify field flag handling
Directly use the hexadecimal representation, just like the
`AnnotationFlags`, to avoid calculations and to improve readability.
This allows us to simplify the unit tests for text widget annotations as
well.
2016-09-21 21:11:37 +02:00
Jonas Jenwald
3a105e37f4 Ensure that test/driver.js actually takes the same Annotation code-path as the viewer when running forms tests (PR 7633 follow-up)
Unfortunately PR 7633 missed, and I didn't catch it during review, to update `test/driver.js` such that the `forms` tests takes the correct code-path.
This resultet in the `forms` reference test images looking better than they should, and more problematicly differing from the rendering in the viewer.

With this patch, the tests now correctly skip over any `Appearance` streams.
The `forms` tests now highlights quite clearly (e.g. look at `annotation-tx2.pdf`/`annotation-tx3.pdf`) that we cannot just skip the `Appearance` streams when rendering forms. Hence we're going to have to find a way to fix that *before* enabling forms by default, since both display *and* print would look completely wrong otherwise.
Finally, this patch also uncovers one more existing bug that still needs to be fixed, since the current `rasterizeAnnotationLayer` in `test/driver.js` isn't able to handle the contents of e.g. `<input>` and `<textarea>`.
2016-09-21 12:21:20 +02:00
Tim van der Meij
6100ab4b18 Text widget annotations: implement comb support 2016-09-20 22:31:10 +02:00
Brendan Dahl
15e1ae4e3f Merge pull request #7639 from Snuffleupagus/bug-1252420
Replace empty CharStrings with '.notdef' in `Type1Font_wrap` to prevent OTS from rejecting the font (bug 1252420)
2016-09-20 11:56:47 -07:00
Jonas Jenwald
170871ab3d Prevent rendering TextWidgetAnnotations in both the core/display layer (issue 7643) 2016-09-18 15:42:22 +02:00
Tim van der Meij
f062695d62 Merge pull request #7633 from timvandermeij/interactive-forms-tx-flags
Text widget annotations: support read-only/multiline fields and improve testing
2016-09-17 17:19:47 +02:00
Tim van der Meij
adf0972ca5 Text widget annotations: improve unit and reference tests
This patch improves the unit tests by testing the support for read-only
and multiline fields. Moreover, we add a reference test to ensure that
the text widgets are not only rendered, but also that their contents are
styled properly.

Finally, we perform minor improvements in `src/core/annotation.js`, for
example adding missing comments.
2016-09-17 15:24:48 +02:00
Jonas Jenwald
aadcbe98c8 Replace empty CharStrings with '.notdef' in Type1Font_wrap to prevent OTS from rejecting the font (bug 1252420)
Fixes https://bugzilla.mozilla.org/show_bug.cgi?id=1252420.
2016-09-17 14:39:10 +02:00
Jonas Jenwald
4acd31f51e Merge pull request #7550 from Snuffleupagus/Type1-toUnicode-builtInEncoding-fallback
For embedded Type1 fonts without included `ToUnicode`/`Encoding` data, attempt to improve text selection by using the `builtInEncoding` to amend the `toUnicode` map (issue 6901, issue 7182, issue 7217, bug 917796, bug 1242142)
2016-09-16 17:51:55 +02:00
Jonas Jenwald
8eaa2cbce3 Remove the deprecated mozDash/mozDashOffset canvas 2D context methods
According to [MDN](https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/setLineDash#Browser_compatibility) the standard versions of these methods have been supported since Firefox 27, which was released over two and a half years ago. (See the dates in https://wiki.mozilla.org/RapidRelease/Calendar#Past_branch_dates)

Furthermore the non-standard properties are now in the process of being removed, please see https://groups.google.com/forum/#!topic/mozilla.dev.platform/UIudMABegcY.
Hence I don't think that we need to keep the old `moz` prefixed ones as fallback any more.
2016-09-15 10:05:40 +02:00
Tim van der Meij
323e86c442 Text widget annotations: implement unit testing and sanitize data values 2016-09-13 14:57:11 +02:00
Jonas Jenwald
356b321f6d Fallback to the StandardEncoding for Nonsymbolic fonts without /Encoding entry (issue 7580)
Even though this patch passes all tests (unit/font/reference) locally, including the new ones that I added in PR 7621, I'm still a bit nervous about modifying the code that choose the fallback encoding for fonts without an `/Encoding` entry.
Note that over the years this code has been changed on a number of occasions, see a possibly incomplete [list here], to deal with various cases of incorrect font data.

According to the PDF specification, see http://www.adobe.com/content/dam/Adobe/en/devnet/acrobat/pdfs/PDF32000_2008.pdf#G8.1904184, it seems that we should fallback to the `StandardEncoding` for Nonsymbolic fonts.
There's obviously a risk that fixing this particular issue *could* break other PDF files for which we don't have tests. However I've tried to change the logic as little as possible in this patch, to hopefully reduce possible breakage.

Based on debugging numerous font issue, it seems that a lot of fonts actually set the Symbolic flag, even when they are in fact *not* Symbolic. Fonts actually marked as Nonsymbolic seem to be somewhat less common, which I hope should reduce the risk of the patch somewhat.

Fixes 7580.
2016-09-13 14:07:16 +02:00
Jonas Jenwald
325f7afcca For embedded Type1 fonts without included ToUnicode/Encoding data, attempt to improve text selection by using the builtInEncoding to amend the toUnicode map (issue 6901, issue 7182, issue 7217, bug 917796, bug 1242142)
Note that in order to prevent any possible issues, this patch does *not* try to amend the `toUnicode` data for Type1 fonts that contain either `ToUnicode` or `Encoding` entries in the font dictionary.

Fixes, or at least improves, issues/bugs such as e.g. 6658, 6901, 7182, 7217, bug 917796, bug 1242142.
2016-09-11 20:54:10 +02:00
Jonas Jenwald
ae2cc9119b Add a couple more, mostly text, reference tests for non-embedded symbolic fonts without included encoding information
I've started to look into how we can fix issue 7580, but quickly became worried that fixing it could easily mean that we'd trade one fixed PDF file for a multitude of broken ones.

Hence I started going through the history of the code that choose the fallback encoding, and noticed that it has been changed a number of times over the years to deal with various cases of weirdness/errors in non-embedded fonts.
To my relief it turned out that almost all the PRs, please see a possibly incomplete [list here], that changed this code actually included `eq` test-cases.

However, in one case it appears that a PR missed to add a test-case. Furthermore since the fallback encoding may also be the only source for creating a `toUnicode` map, changing the encoding could possibly regress only the text-selection despite a PDF file still rendering correctly.
Therefore, this PR adds one new `eq` test, and also a number of additional `text` tests for PDF files already present in the test-suite.

Note that it's obviously possible that there's a certain overlap between the added tests, but I'd be *a whole lot* more concerned with causing regressions.
2016-09-11 16:38:39 +02:00
Jonas Jenwald
0b75f63c03 Don't duplicate the first entry in the charCodeToGlyphId map for CIDFontType2 fonts with a CIDToGIDMap that already mapped the first entry to a non-zero glyphId (issue 7544)
Fixes 7544.
2016-09-09 22:33:41 +02:00
Tim van der Meij
b112f9f9f4 Merge pull request #7600 from Snuffleupagus/issue-7598
Check that Type1C fonts does not actually contain OpenType font files (issue 7598)
2016-09-09 22:02:58 +02:00
Tim van der Meij
e281ce7c73 Enable regression testing for interactive forms 2016-09-07 16:50:44 +02:00
Jonas Jenwald
44b75c01a1 Check that Type1C fonts does not actually contain OpenType font files (issue 7598)
This patch is yet another instalment in the (never ending) series of patches for PDF files that specify completely incorrect Type/Subtype for its fonts. In this case Type1/Type1C, when in fact OpenType would have been correct.

Fixes 7598.
2016-09-06 10:13:11 +02:00
Jonas Jenwald
37998076c9 In display/api.js ensure that we always reject with an Error in JpegDecode, and adjust a couple of other rejection sites as well
In the case where the document was destroyed, we were rejecting the `Promise` in `JpegDecode` with a string instead of an `Error`. The patch also brings the wording more inline with other such rejections.

Use the `isInt` utility function when validating the `pageNumber` parameter in `WorkerTransport_getPage`, to make it more obvious what's actually happening. There's also a couple more unit-tests added, to ensure that we always fail in the expected way.

Finally, we can simplify the rejection handling in `WorkerTransport_getPageIndexByRef` somewhat. (Note that the only reason for using `catch` here is that since the promise is rejected on the worker side, the `reason` becomes a string instead of an `Error` which is why we "re-reject" on the display side.)
2016-09-05 16:35:32 +02:00
Tim van der Meij
d03651efff Merge pull request #7407 from Snuffleupagus/issue-7406
Assign the `quantizationTables` after parsing the entire JPEG image, to prevent issues when the DQT (Define Quantization Tables) marker is encountered after SOF{n} (Start of Frame) markers (issue 7406)
2016-09-04 14:49:01 +02:00
Tim van der Meij
6bb95e3129 Merge pull request #7539 from jeremypress/fairexpand
[api-minor] Expanding divs to improve selection
2016-09-01 17:43:31 +02:00
Jeremy Press
1ceeb4d17b added text enhancement regression tests 2016-08-31 09:54:52 -07:00
Jeremy Press
6faa84abdb Continuing fairexpand #6663
1. Expanding divs to improve text selection. (Yury)
2. Adding enhanceTextSelection as an option.
3. Moving feature functionality from text_layer_builder.js to text_layer.js.
4. Added expandTextDivs method to only load expanded divs on first click, and only show on subsequent clicks
2016-08-31 09:54:52 -07:00
Jonas Jenwald
3ac23200ba Add a reduced test-case for issue 7406
The PDF file contains an image that we're allowed to use, since it's just the PDF.js logo.
The logo image was simply inverted (so that it requires a /Decode entry in the image dictionary that triggers the use of `jpg.js` instead of the browser), converted to JPEG, and finally edited by hand to change the order of the DQT/SOF{n} markers.
2016-08-31 18:42:07 +02:00
Yury Delendik
ffa99397ad Merge pull request #7387 from Snuffleupagus/issue-5808
Attempt to ignore multiple identical Tf (setFont) commands in `PartialEvaluator_getTextContent` (issue 5808)
2016-08-30 15:21:41 -05:00
Tim van der Meij
f520616e00 Merge pull request #7570 from Snuffleupagus/issue-7569
Create a fallback annotation `id` for entries in `Annots` dictionaries that are not indirect objects (issue 7569)
2016-08-28 00:23:59 +02:00
Tim van der Meij
b81d661556 Remove unused globals from fonts unit test file 2016-08-27 23:20:03 +02:00
Jonas Jenwald
088ce6c009 Add a unit-test to check that ProblematicCharRanges contains valid entries
When adding new entries to `ProblematicCharRanges`, you have to be careful to not make any mistakes since that could cause glyph mapping issues.
Currently the existing reference tests should probably help catch any errors, but based on experience I think that having a unit-test which specifically checks `ProblematicCharRanges` would be both helpful and timesaving when modifying/reviewing changes to this code.

Hence this patch which adds a function (and unit-test) that is used to validate the entries in `ProblematicCharRanges`, and also checks that we don't accidentally add more character ranges than the Private Use Area can actually contain.
The way that the validation code, and thus the unit-test, is implemented also means that we have an easy way to tell how much of the Private Use Area is potentially utilized by re-mapped characters.
2016-08-27 11:56:00 +02:00
Jonas Jenwald
78889646c8 Create a fallback annotation id for entries in Annots dictionaries that are not indirect objects (issue 7569)
According to the PDF specification, see http://www.adobe.com/content/dam/Adobe/en/devnet/acrobat/pdfs/PDF32000_2008.pdf#page=86, entries in `Annots` dictionaries should be indirect objects, but obviously there're PDF generators that ignore this.

Fixes 7569.
2016-08-27 10:56:16 +02:00
Jonas Jenwald
db1526c59e Add unit-tests for asynchronous methods in primitives.js
In PR 7520, I missed the fact that we currently have no unit-tests for `Dict_getAsync`.
2016-08-21 18:44:58 +02:00
Tim van der Meij
b4c8814fc9 Merge pull request #7534 from Snuffleupagus/isName-name-check
Add a parameter to the `isName` function that enables checking not just that something is a `Name`, but also that the actual `name` properties matches
2016-08-17 15:48:42 +02:00
Jonas Jenwald
544d29f5cb Add a recoveryMode that suppresses errors from the Parser, and utilize it when searching for the main trailer in XRef_indexObjects (bug 1250079)
Instead of having `Parser_getObj` fail unconditionally for the referenced PDF file, this patch attempts to let searching for the main trailer continue even if there are errors.

Fixes https://bugzilla.mozilla.org/show_bug.cgi?id=1250079.
2016-08-17 12:37:35 +02:00
Jonas Jenwald
af636aae96 Add a parameter to the isName function that enables checking not just that something is a Name, but also that the actual name properties matches
This is similar to the existing `isCmd` and `isDict` functions, which already support similar kind of checks.
With the updated `isName` function, we'll be able to simplify many callsites from: `isName(someVariable) && someVariable.name === 'someName'` to: `isName(someVariable, 'someName')`.
2016-08-10 11:15:03 +02:00
Jonas Jenwald
d70e07fb90 Add more unit-tests for primitives.js 2016-08-03 17:04:12 +02:00
Jonas Jenwald
77c6ed5389 Attempt to ignore multiple identical Tf (setFont) commands in PartialEvaluator_getTextContent (issue 5808)
This patch improves the performance of issue 5808, but I'm not sure if it's enough to call it fixed. On average, this patch reduces the number of textLayer div's by a factor of 3, and it also reduces the time spend in `getTextContent` by a factor of ~2.

The PDF file is generated by `Scribus PDF`, which for reasons I cannot understand is placing redundant `Tf` commands before *every* showText command.
Note how the PDF file also contains lots of (basically) identical fonts, but with slightly different names, which causes unnecessary font-switching. This causes some unnecessary breaking of textLayer div's, but this issue cannot be easily worked around.
2016-07-27 21:37:52 +02:00
Yury Delendik
a02e2686b9 Merge pull request #7475 from Snuffleupagus/api-getTextContent-combineTextItems
[api-minor] Add a parameter to `PDFPageProxy_getTextContent` that controls whether `PartialEvaluator_getTextContent` will attempt to combine same line text items
2016-07-27 08:34:24 -05:00
Jonas Jenwald
558a22cd02 Prevent errors when parsing Annotations with missing (or invalid) /Subtype entries (issue 7446)
Note that I used a separate warning message for this case, instead of utilizing the same one as in the unsupported subtype case, to more clearly indicate that the PDF file itself is to blame rather than PDF.js.

Fixes 7446.
2016-07-25 13:59:26 +02:00
Brendan Dahl
5678486802 Merge pull request #7347 from Snuffleupagus/evaluator-more-Ref_toString
Slightly refactor the `fontRef` handling in `PartialEvaluator_loadFont` (issue 7403 and issue 7402)
2016-07-22 17:21:47 -07:00
Brendan Dahl
50d6e4f147 Merge pull request #7447 from Snuffleupagus/buildToUnicode-notdef
Ignore .notdef in the `differences` array when building a fallback `toUnicode` map in `PartialEvaluator_buildToUnicode` (issue 5256)
2016-07-22 14:33:32 -07:00
Jonas Jenwald
4fe891c5e7 Add a reduced test-case for issue 7403 2016-07-21 16:04:07 +02:00
Tim van der Meij
10f9f11ec4 Merge pull request #7490 from Snuffleupagus/issue-7426
Don't map glyphs to the Lepcha Unicode block (issue 7426)
2016-07-21 14:39:19 +02:00
Jonas Jenwald
f297e4d17c [api-minor] Add a parameter to PDFPageProxy_getTextContent that controls whether PartialEvaluator_getTextContent will attempt to combine same line text items
From the discussion in issue 7445, it seems that there may be cases where an API consumer would want to get the text content as is, without combined text items.
2016-07-19 13:38:57 +02:00
Jonas Jenwald
90d19de935 Catch errors and continue parsing in parseCMap (issue 7492)
After PR 7039, the PDF file in issue 7492 no longer renders at all, but note that text selection wasn't working correctly previously.

The problem with the PDF file in issue 7492 is that the `cMap`, in the `toUnicode` entry in the font, contains an invalid name:
```
/CMapName /-usr-share-fonts-truetype-Panton-Panton Family-Fontfabric - Panton.otf,000-UTF16 def
```
When we parse that line, things obviously break because there are spaces present in the wrong places.
To avoid that issue, the patch simply lets `parseCMap` continue when errors are encountered, to try and recover usable data. Note that by not aborting immediatly when an error is encountered, we are also able to fix the text selection.

Obviously, it could be argued that we should just immediatly reject a corrupt `cMap`. But given that they usually are correct, it seems that trying to recover as much data as possible from corrupt one can only be a good thing for both glyph mapping and text selection.

Fixes 7492.
2016-07-18 16:39:56 +02:00
Jonas Jenwald
64783c8b6e Don't map glyphs to the Lepcha Unicode block (issue 7426)
In the PDF file in the issue, some of the glyphs end up being mapped to the Lepcha Unicode block; see https://en.wikipedia.org/wiki/Lepcha_(Unicode_block).
This didn't use to matter, but after HarfBuzz updates that improved support for Lepcha fonts, in particular https://bugzilla.mozilla.org/show_bug.cgi?id=1249861, some glyphs are now moved horizontally.
To avoid that, this patch adds the Lepcha block to the list of Unicode ranges that we skip when building the glyph mapping.

Fixes 7426.
2016-07-17 16:53:36 +02:00
klemens
6f03f62327 trivial spelling fixes 2016-07-17 14:33:41 +02:00
Brendan Dahl
1f3f4a8dd7 Merge pull request #7441 from Snuffleupagus/issue-7439
Fallback to attempt to recover standard glyph names when amending the `charCodeToGlyphId` with entries from the `differences` array in `type1FontGlyphMapping` (issue 7439)
2016-07-06 13:02:21 -07:00
Jonas Jenwald
72c1df726e Add a getAttachments unit-test for a PDF file that actually contains attachments 2016-07-02 13:13:30 +02:00
Brendan Dahl
e2e657e44f Merge pull request #7390 from Snuffleupagus/issue-7180
Add upper-case `I` as a possible space replacement fallback in `Font.spaceWidth` to improve text-selection (issue 7180)
2016-06-29 15:11:19 -07:00
Jonas Jenwald
bdd58ab1d2 Ignore .notdef in the differences array when building a fallback toUnicode map in PartialEvaluator_buildToUnicode (issue 5256)
Fixes 5256.
2016-06-27 16:20:23 +02:00
Jonas Jenwald
7866109af9 Fallback to attempt to recover standard glyph names when amending the charCodeToGlyphId with entries from the differences array in type1FontGlyphMapping (issue 7439)
Fixes 7439.
2016-06-25 14:54:34 +02:00
Tim van der Meij
f97d52182a Merge pull request #7341 from Snuffleupagus/getDestinationHash-Array
[api-minor] Improve handling of links that are using explicit destination arrays
2016-06-09 00:29:10 +02:00
Jonas Jenwald
6a0b047bfa Add upper-case I as a possible space replacement fallback in Font.spaceWidth to improve text-selection (issue 7180)
In fonts with only upper-case glyphs, that are also missing a space glyph, `get spaceWidth` won't be able to return anything useful.
By adding upper-case `I` as a fallback, we can thus improve text-selection in some PDF files.
Note that locally, the patch causes slight movement in a few existing `text` tests, but in my opinion this actually looks like slight improvements.

Fixes 7180.
2016-06-07 22:55:25 +02:00
Jonas Jenwald
6260fc09a3 Attempt to recover valid format 3 FDSelect data from broken CFF fonts (bug 1146106)
According to the CFF specification, see http://partners.adobe.com/public/developer/en/font/5176.CFF.pdf#G3.46884, for `format 3` FDSelect data: "The first range must have a ‘first’ GID of 0".
Since the PDF file (attached in the bug) violates that part of the specification, this patch tries to recover valid FDSelect data to prevent OTS from rejecting the font.

Fixes https://bugzilla.mozilla.org/show_bug.cgi?id=1146106.
2016-06-06 18:20:52 +02:00
Yury Delendik
f0585f5d65 Merge pull request #7370 from Rob--W/crx-telemetry-7312
Add opt-out telemetry to the Chrome extension
2016-06-03 15:48:46 -05:00
Rob Wu
724308c57a Add opt-out telemetry to the Chrome extension
Privacy policy: https://github.com/Rob--W/pdfjs-telemetry#privacy-policy

Unit tests (offline):

```
node test/chromium/test-telemetry.js
```

Server tests (requires that Nginx is installed):

```
git clone https://github.com/Rob--W/pdfjs-telemetry.git
cd pdfjs-telemetry/
python testserver.py TestHttp TestHttps
```

Integration test (extension + server):

- Build the extension
- Edit build/chromium/telemetry.js and remove the check for
  chrome.runtime.id.
- Start Chrome (preferably a new profile):
  chromium --user-data-dir=/tmp/pdftest --no-first-run
- Open chrome://net-internals#events
- Visit chrome://extensions and enable Developer mode.
- Load unpacked extension, select build/chromium.
- Go to the chrome://net-internals tab and filter on pdfjs.robwu.nl.
- Click on URL_REQUEST and verify that the server replied with 204.
- Reload the extension.
- Verify that chrome://net-internals did not contain a new log request.
2016-06-03 20:36:57 +02:00
Jonas Jenwald
b02d560ae0 Fix errors in setGState in PartialEvaluator_getTextContent that prevents text-selection from working properly
Currently `setGState` is completely broken, and looking through the history of that code, it seems to me that this may never have worked correctly.
This patch fixes the text-selection in `extgstate.pdf` in the test-suite, which is also added as a `text` test.
2016-06-01 22:58:49 +02:00
Jonas Jenwald
98fe094d18 Let non-viewable Popup Annotations inherit the parent's Annotation Flags if the parent is viewable
Fixes http://www.pdf-archive.com/2013/09/30/file2/file2.pdf.

Note how it's not possible to show the various Popup Annotations in the above document.
To fix that, this patch lets the Popup inherit the flags of the parent, in the special case where the parent is `viewable` *and* the Popup is not.
In general, I don't think that a Popup must have the same flags set as the parent. However, it seems very strange to have a `viewable` parent annotation, and then not being able to view the Popup.

Annoyingly the PDF specification doesn't, as far as I can find, mention anything about how this case should be handled, but this patch seem consistent with the actual behaviour in Adobe Reader.
2016-05-25 23:00:26 +02:00
Brendan Dahl
b86610ffdb Merge pull request #7300 from Snuffleupagus/bug-1068432
Prevent adding invalid values in `CFFDict_setByKey` (bug 1068432)
2016-05-24 12:12:38 -07:00
Jonas Jenwald
b354682dd6 [api-minor] Let LinkAnnotation/PDFLinkService_getDestinationHash return a stringified version of the destination array for explicit destinations
Currently for explicit destinations, compared to named destinations, we manually try to build a hash that often times is a quite poor representation of the *actual* destination. (Currently this only, kind of, works for `\XYZ` destinations.)
For PDF files using explicit destinations, this can make it difficult/impossible to obtain a link to a specific section of the document through the URL.

Note that in practice most PDF files, especially newer ones, use named destinations and these are thus unnaffected by this patch.
This patch also fixes an existing issue in `PDFLinkService_getDestinationHash`, where a named destination consisting of only a number would not be handled correctly.

With the added, and already existing, type checks in place for destinations, I really don't think that this patch exposes any "sensitive" internal destination code not already accessible through normal hash parameters.

*Please note:* Just trying to improve the algorithm that generates the hash is unfortunately not possible in general, since there are a number of cases where it will simply never work well.

 - First of all, note that `getDestinationHash` currently relies on the `_pagesRefCache`, hence it's possible that the hash returned is empty during e.g. ranged/streamed loading of a PDF file.

 - Second of all, the currently computed hash is actually dependent on the document rotation. With named destinations, the fetched internal destination array is rotational invariant (as it should be), but this will not hold in general for the hash. We can easily avoid this issue by using a stringified destination array.

 - Third of all, note that according to the PDF specification[1], `GoToR` destinations may actually contain explicit destination arrays. Since we cannot really construct a hash in `annotation.js`, we currently have no good way to support those. Even though this case seems *very* rare in practice (I've not actually seen such a PDF file), it's in the specification, and this patch allows us to support that for "free".

---
[1] http://www.adobe.com/content/dam/Adobe/en/devnet/acrobat/pdfs/PDF32000_2008.pdf#G11.1951685
2016-05-21 14:14:07 +02:00
Jonas Jenwald
01ab15a6f1 [api-minor] Let Catalog_getPageIndex check that the Ref actually points to a /Page dictionary
Currently the `getPageIndex` method will happily return `0`, even if the `Ref` parameter doesn't actually point to a proper /Page dictionary.
Having the API trust that the consumer is doing the right thing seems error-prone, hence this patch which adds a check for this case.

Given that the `Catalog_getPageIndex` method isn't used in any hot part of the codebase, this extra check shouldn't be a problem.
(Note: in the standard viewer, it is only ever used from `PDFLinkService_navigateTo` if a destination needs to be resolved during document loading, which isn't common enough to be an issue IMHO.)
2016-05-21 14:13:41 +02:00
Tim van der Meij
db46829ef7 Merge pull request #7316 from timvandermeij/remove-unused
Remove unused variables
2016-05-21 14:07:33 +02:00
Jonas Jenwald
c5c5a2a71f Add basic unit-tests for unicode.js
Re: issue 7261.
2016-05-19 19:45:45 +02:00
Jonas Jenwald
7ddb0bc718 Attempt to combine text runs positioned with setTextMatrix 2016-05-18 17:21:58 +02:00
Tim van der Meij
6a7012aaca Remove unused variables
These have been found using `gulp lint` in combination with the `unused:
true` parameter for JSHint. Unfortunately there are too many false
positives to enable this feature, but now that most globals have been
removed because of the conversion to UMD the results are much more
useful than before.
2016-05-11 16:11:13 +02:00
Jonas Jenwald
182d33800a Ignore 'endobj' commands inside of ObjStm streams (issue 5241, bug 898610, bug 1037816)
According to an example in the PDF specification, see http://www.adobe.com/content/dam/Adobe/en/devnet/acrobat/pdfs/PDF32000_2008.pdf#page=56, an `ObjStm` stream should not contain 'endobj' commands.

Fixes 5241.
Fixes https://bugzilla.mozilla.org/show_bug.cgi?id=898610.
Fixes https://bugzilla.mozilla.org/show_bug.cgi?id=1037816.
2016-05-09 09:50:45 +02:00
Jonas Jenwald
c9b6de3b16 Prevent adding invalid values in CFFDict_setByKey (bug 1068432)
In the font in question, there are a couple of `topDict` entries that have invalid values (`0xF 0xF`, i.e. just eof markers without any actual numbers).
This causes the `parseFloatOperand` function, inside `CFFParser_parseDict`, to return `NaN`. Currently we pass this broken font onto the browser, which OTS unsurprisingly rejects.

Fixes https://bugzilla.mozilla.org/show_bug.cgi?id=1068432.
2016-05-07 21:09:58 +02:00
Jonas Jenwald
29c4a604af Split the font_spec.js unit-tests into cff_parser_spec.js and type1_parser_spec.js
Re: issue 7261.

Given the we have `gulp fonttest`, which tests the `fonts.js` functionality at a higher level, and that we have *a lot* of font specific reference tests, I'm not convinced that we *also* need unit-tests for it.
2016-05-03 09:37:36 +02:00
Yury Delendik
7fd3db9977 Adds EventBus. 2016-04-28 06:57:24 -05:00
Jonas Jenwald
293901d7e5 Add a (linked) test-case for issue 3248 2016-04-21 16:36:46 +02:00
Jonas Jenwald
e281ef15db Adjust incorrect first obj number of "free" xref entry in XRef_readXRefTable (issue 7229)
Fixes 7229.
2016-04-21 16:36:32 +02:00
Jonas Jenwald
b4a17323b6 Move isDict unit-tests from util_spec.js to primitives_spec.js
This patch moves the unit-test to the correct file, since the `isDict` function was moved PR 6683.
2016-04-16 20:32:46 +02:00
Jonas Jenwald
4523ae0b91 Add a couple of CipherTransformFactory unit-tests to check that blank passwords are correctly rejected 2016-04-16 20:24:55 +02:00
Jonas Jenwald
171f908b89 Add a couple of LinkAnnotation unit-tests
We currently don't have *any* unit-tests for `LinkAnnotation`s, so it seemed a good idea to add a few. These tests are taken from various actual PDF files.
2016-04-15 22:59:08 +02:00
Tim van der Meij
4a601ffc28 Merge pull request #7197 from prakashpalanisamy/remove-combineurl-test
Remove `combineUrl` and replace it with `new URL`. Issue #7183, for reference.
2016-04-15 22:44:07 +02:00
Prakash Palanisamy
a25c29d98d Remove combineUrl and replace it with new URL. 2016-04-15 21:33:10 +05:30
Jonas Jenwald
079b563e2d Ensure that the params parameter of the PredictorStream is a dictionary (issue 7200)
Fixes 7200.
2016-04-15 16:30:18 +02:00
Yury Delendik
6282ec24d1 Merge pull request #7172 from yurydelendik/umd-web
Introduces UMD headers to the web/ folder.
2016-04-13 10:23:23 -05:00
Yury Delendik
006e8fb59d Introduces UMD headers to the web/ folder. 2016-04-13 10:09:48 -05:00
Yury Delendik
398e6acbc5 Stops bleeding of pattern edges for mesh. 2016-04-11 18:21:44 -05:00
Jonas Jenwald
be6754a1a0 Merge pull request #7176 from yurydelendik/smask-resume
Allow SMask be resumed after restore() and better transform after SMask
2016-04-11 15:57:40 +02:00
Yury Delendik
d76db416f4 Adds more SMask tests. 2016-04-11 08:02:06 -05:00
Yury Delendik
879340d741 Removes hijack describe() hack from unit tests. 2016-04-11 07:37:35 -05:00
Yury Delendik
44c63bca28 Merge pull request #7175 from Snuffleupagus/issue-6905-font_spec
Use `beforeAll`/`afterAll` in font_spec.js (issue 6905)
2016-04-11 07:20:45 -05:00
Yury Delendik
070f2d32ad Merge pull request #7171 from Snuffleupagus/remove-new-Name/Cmd
Remove the remaining usages of `new {Name,Cmd}` in favor of `{Name,Cmd}.get`
2016-04-11 07:17:30 -05:00
Jonas Jenwald
c4e21c93a2 Use beforeAll/afterAll in font_spec.js (issue 6905)
This patch fixes the only remaining point in issue 6905.
2016-04-10 16:09:11 +02:00
Jonas Jenwald
b0ce83b372 Use beforeAll/afterAll in CipherTransformFactory in crypto_spec.js (issue 6905
This patch also adds/improves utility functions for checking if the passwords are correct/incorrect, and replaces `string2binary` with `stringToBytes`. Finally the patch does away with the `DictMock`, in favour of using actual `Dict`s.

Re: issue 6905.
2016-04-10 13:20:21 +02:00
Jonas Jenwald
f59c3a0644 Remove the remaining usages of new {Name,Cmd} in favor of {Name,Cmd}.get
Using `new {Name,Cmd}` should be avoided, since it creates a new object on *every* call, whereas `{Name,Cmd}.get` uses caches to only create *one* object regardless of how many times they are called.

Most of these are found in the unit-tests, where increased memory usage probably doesn't matter very much. But it still seems good to get rid of those cases, since no part of the codebase ought to advertise that usage.

Given the small size of the patch, I'm also tweaking a few comments and class names.
2016-04-08 12:14:05 +02:00
Brendan Dahl
68e8f5fff5 Merge pull request #7126 from yurydelendik/rm-pdfjs-display
Move all PDFJS display/ usages into global.js file.
2016-04-07 11:47:58 -07:00
Yury Delendik
1d12aed5ca Move all PDFJS.xxx settings into display/global. 2016-04-07 13:46:07 -05:00
Jonas Jenwald
c6c5b8fab8 Use beforeAll/afterAll in isExternalLinkTargetSet in dom_utils_spec.js (issue 6905)
Re: issue 6905.
2016-04-07 14:00:40 +02:00
Jonas Jenwald
ef551e8266 Extract Type1Parser from fonts.js 2016-04-01 23:38:53 +02:00
Jonas Jenwald
b961e1d21b Extract CFFParser from fonts.js (issue 6777) 2016-04-01 22:32:39 +02:00
Yury Delendik
ff3ce973b8 Merge pull request #7106 from Snuffleupagus/issue-7101
Keep track of the character to glyph mapping in font_renderer.js, to prevent errors when different characters point to the same glyph (issue 7101)
2016-04-01 08:09:21 -05:00
Jonas Jenwald
05cf709f8e Parse Type1 font files to determine the various Length{n} properties, instead of trusting the PDF file (issue 5686, issue 3928)
Fixes 5686.
Fixes 3928.
2016-03-31 11:08:12 +02:00
Jonas Jenwald
7163e1eff3 Faster unit-tests by using beforeAll/afterAll in api_spec.js
In the API unit-tests, we're currently loading the `basicapi.pdf` before every sub-test in `PDFDocument` and `Page`, which slows down the unit-tests quite a bit.
Locally this patch reduces the run time for `gulp unittest` by at least 40% for me.
2016-03-30 15:32:01 +02:00
Jonas Jenwald
17aaa125df Keep track of the character to glyph mapping in font_renderer.js, to prevent errors when different characters point to the same glyph (issue 7101)
Fixes 7101.
2016-03-30 11:33:04 +02:00
Yury Delendik
bec4891f5d Merge pull request #7102 from brendandahl/onerror
Log uncaught global errors.
2016-03-29 17:23:28 -05:00
Jonas Jenwald
ac772017b6 Add unit-tests for destionations in /Names (NameTree) dictionaries where all entries are indirect objects
Re: issue 6204 and PR 6208.
2016-03-29 17:55:05 +02:00
Yury Delendik
df0cbccfd8 Merge pull request #7129 from yurydelendik/jasmine
Updates Jasmine version.
2016-03-29 10:32:17 -05:00
Yury Delendik
0a700fa29d Updates Jasmine version. 2016-03-29 09:34:13 -05:00
Tim van der Meij
553928c26e Merge pull request #7118 from Snuffleupagus/issue-7115
Prevent failures in the Annotation code if the `Rect` array contains indirect objects (issue 7115)
2016-03-29 00:04:59 +02:00
Jonas Jenwald
8f097abb46 Allow unit-tests to use linked PDF files, by having the unittest command download unavailable ones (issue 7117) 2016-03-27 13:17:55 +02:00
Jonas Jenwald
13d7a5070e Prevent failures in the Annotation code if the Rect array contains indirect objects (issue 7115)
Note that in the PDF files provided by the reporter, this issue was limited to `Rect` arrays in AcroForm entries (which we currently don't support).
However, since a bad PDF generator could create this problem in *any* kind of annotation, the reduced test-case included here uses a simple LinkAnnotation instead.

Fixes 7115.
2016-03-26 20:55:16 +01:00
Brendan Dahl
df7afcf004 Merge pull request #7053 from yurydelendik/rm-pdfjs-core
Removes global PDFJS usage from the src/core/.
2016-03-25 13:19:43 -07:00
Yury Delendik
a505aa8e90 Disables issue6961 test. 2016-03-25 12:48:11 -05:00
Yury Delendik
a8e5912cb1 Moves shared/global to display/global 2016-03-23 19:24:37 -05:00
Yury Delendik
bda5e6235e Removes global PDFJS usage from the src/core/. 2016-03-23 19:24:37 -05:00
Brendan Dahl
fb47490648 Log uncaught global errors. 2016-03-22 15:49:32 -07:00
Manas
f6d28ca323 Refactors CMapFactory.create to make it async 2016-03-21 23:08:19 +05:30
Jonas Jenwald
dfe9015a43 Convert uniXXXX glyph names to proper ones when building the charCodeToGlyphId map for TrueType fonts (bug 1132849, issue 6893, issue 6894)
This patch adds a `getUnicodeForGlyph` helper function, which is used to recover Unicode values for non-standard glyph names.

Some PDF generators, e.g. Scribus PDF, use improper `uniXXXX` glyph names which breaks the glyph mapping. We can avoid this by converting them to "standard" glyph names instead.

Fixes https://bugzilla.mozilla.org/show_bug.cgi?id=1132849.
Fixes 6893.
Fixes 6894.
2016-03-09 19:37:15 +01:00
Preetham Mysore
be1e12dbcb Fix for descent calculation while reading font hhea headers 2016-03-03 08:51:41 -05:00
Jonas Jenwald
8402c79171 Merge pull request #7050 from brendandahl/issue4402
For CIDFontType2 use CID as glyph ID when missing CID to GID map.
2016-03-02 10:11:42 +01:00
Brendan Dahl
a6acf74b54 Merge pull request #7023 from brendandahl/issue6721
Only draw glyphs on canvas if they are in the font or the font file is missing.
2016-03-01 18:03:37 -08:00
Brendan Dahl
6e1d131384 For CIDFontType2 use CID as glyph ID when missing CID to GID map. 2016-03-01 17:05:33 -08:00
Brendan Dahl
ff87f3fb86 Only draw glyphs on canvas if they are in the font or the font file is missing. 2016-03-01 13:24:58 -08:00
Jonas Jenwald
505f15f221 Avoid accidentally getting the entire font file in readNameTable (issue 7020)
In the PDF file in question, some of the 'name' table entries have `record.length === 0`. This becomes problematic in the non-unicode case, since `font.getBytes(0)` will fetch the *entire* stream.
Given that OTS rejects 'name' entries larger than `2^16`, this thus explain the sanitizer errors.

Fixes 7020.
2016-03-01 21:59:49 +01:00
Yury Delendik
22341c0761 Merge pull request #6879 from yurydelendik/streams
Makes PDF data reading Streams API friendly.
2016-03-01 09:10:52 -06:00
Tim van der Meij
ad31e52a26 Group popup creation code and apply it to more annotation types 2016-02-25 00:35:45 +01:00
Jonas Jenwald
41efb92d3a Merge pull request #6988 from timvandermeij/fileattachment-annotation
Implement support for FileAttachment annotations
2016-02-24 12:58:06 +01:00
Tim van der Meij
0351c7eff4 Move the getFileName helper function to the core
This is required to be able to use it in the annotation display code,
where we now apply it to sanitize the filename of the FileAttachment
annotation. The PDF file from https://bugzilla.mozilla.org/show_bug.cgi?id=1230933 has shown that some PDF generators include the path of the file rather than the filename, which causes filenames with weird initial characters. PDF viewers handle this differently (for example Foxit Reader just replaces forward slashes with spaces), but we think it's better to only show the filename as intended.

Additionally we add unit tests for the `getFilenameFromUrl` helper
function.
2016-02-23 22:49:53 +01:00
Tim van der Meij
10902fd882 Implement unit and reference testing for FileAttachment annotations 2016-02-23 22:49:53 +01:00
Yury Delendik
0d591719d9 Makes PDF data reading Streams API friendly. 2016-02-18 13:17:53 -06:00
Jonas Jenwald
a494e33776 Update JpegImage.getData to support forceRGBoutput for images with numComponents === 1 (issue 6066)
*A more robust solution for issue 6066.*

As a temporary work-around for (the upstream) [bug 1164199](https://bugzilla.mozilla.org/show_bug.cgi?id=1164199), we parsed *all* images in the Firefox addon during a short time.
Doing so uncovered an issue with our image handling (see 6066), for JPEG images with a `DeviceGray` ColorSpace *and* `bpc !== 1` (bits per component).

As long as we let the browser handle image decoding in this case, this isn't going to be an issue, but I do think that we should proactively fix this to avoid future issues if we change where the images are decoded (in `jpg.js` vs in browser).
Also, we currently don't seem to have a test-case for that kind of image data.
2016-02-18 10:12:37 +01:00
Jonas Jenwald
7cf9de2c17 [api-minor] Change getOutline to actually return the RGB color of outline items
Currently the `C` entry in an outline item is returned as is, which is neither particularly useful nor what the API documentation claims.

This patch also adds unit-tests for both the color handling, and the `F` entry (bold/italic flags).
2016-02-15 13:41:22 +01:00
Jonas Jenwald
98db068079 Reduce the overall indentation level in Catalog_readDocumentOutline, by using early returns, in order to improve readability 2016-02-14 11:38:43 +01:00
Jonas Jenwald
62b17ad36e Add a linked load test for issue 6549 2016-02-12 18:10:07 +01:00
Jonas Jenwald
07e1ad40a2 Replace getAll with getKeys in PartialEvaluator_hasBlendModes to speed up loading of badly generated PDF files (issue 6961)
Some bad PDF generators, in particular "Scribus PDF", duplicates resources *a lot* at various levels of the PDF files. This can lead to `PartialEvaluator_hasBlendModes` taking an unreasonable amount of time to complete.
The reason is that the current code is using `Dict_getAll`, which recursively dereferences *all* indirect objects, which can be really slow. This patch instead uses `Dict_getKeys`, and then manually looks up only the necessary indirect objects.

I've added the PDF file as a `load` test. The most important thing here is probably to ensure that the file remains available in the repo, and the comment should help reduced the chance of regressions. (Note that locally, the `load` test times out without this patch, but we cannot really assume that that always happens.)

Fixes 6961.
2016-02-10 17:21:38 +01:00
Tim van der Meij
5bcf4c1895 Destroy workers when they are no longer needed in the unit tests 2016-01-29 12:23:17 +01:00
Jonas Jenwald
1140a34f5c [api-minor] Change getPageLabels to always return the pageLabels, even if they are identical to standard page numbering 2016-01-27 13:36:03 +01:00
Jonas Jenwald
15ce96a6eb Prevent failures in the "scanning for endstream" code, in Parser_makeStream, by handling the case where 'endstream' is split between contiguous chunks (issue 1536) 2016-01-26 09:03:51 +01:00
Tim van der Meij
58329f7f92 Merge pull request #6803 from Snuffleupagus/page-labels
[api-minor] Add support for PageLabels in the API
2016-01-20 22:05:48 +01:00
Yury Delendik
0aa373cdf3 Merge pull request #6891 from Snuffleupagus/issue-6889
Map missing glyphs to the `notdef` glyph for TrueType (3, 1) fonts regardless if the 'post' table is defined or not (issue 6889)
2016-01-20 13:14:47 -06:00
Jonas Jenwald
85cf90643f [api-minor] Add support for PageLabels in the API 2016-01-19 22:49:04 +01:00
Tim van der Meij
1eea0db897 Merge pull request #6822 from Snuffleupagus/urls-in-outline
[api-minor] Add support for URLs in the document outline
2016-01-19 22:21:40 +01:00
Jonas Jenwald
0030a82dc3 [api-minor] Add support for URLs in the document outline
Re: issue 5089.
(Note that since there are other outline features that we currently don't support, e.g. bold/italic text and custom colours, I thus think we can keep the referenced issue open.)
2016-01-19 21:36:27 +01:00
Jonas Jenwald
d9e21a3523 Merge pull request #6895 from timvandermeij/issue-6854-final
Update links to point to the Internet Archive for issue2799 and issue5726
2016-01-18 21:00:14 +01:00
Tim van der Meij
ec066101d8 Merge pull request #6848 from Snuffleupagus/recover-missing-glyf-table
[TrueType] Recover from a missing "glyf" table by replacing it with dummy data, utilizing the existing code in `sanitizeGlyphLocations`
2016-01-18 20:28:52 +01:00
Tim van der Meij
10a55087b5 Update links to point to the Internet Archive for issue2799 and
issue5726

We remove yo01. The file is not available, it was introduced in
3529658ac5
along with another test file (so we should not need it) and it was
replaced in
6b2c6fc223,
so it was only in the repository for a very short time.
2016-01-18 15:53:07 +01:00
Jonas Jenwald
4855d4cc9f Map missing glyphs to the notdef glyph for TrueType (3, 1) fonts regardless if the 'post' table is defined or not (issue 6889) 2016-01-17 22:58:00 +01:00
Tim van der Meij
57246c15c7 Update links to point to the Internet Archive for issue1597, issue2627 and kdchart 2016-01-17 14:36:17 +01:00
Jonas Jenwald
da75671199 Remove 'issue2537.pdf.link', since it has been replaced with a reduced test-case
In PR 4732, Yury replaced the linked test, but apparently the .link file stuck around despite not being needed anymore.

Re: PR 6854.
2016-01-17 14:04:00 +01:00
Jonas Jenwald
f80a6efce3 Issue 6854 - Update the link locations to point to the Internet Archive for tests: issue2829, issue2853, issue2881, issue3062, issue3999 2016-01-17 13:15:42 +01:00
Jonas Jenwald
b4020047bc Replace the linked test-case for issue 1155 with a reduced one
As part of the link cleanup in issue 6854, obtaining this file through the Internet Archive didn't work.
However, given that the file was added in order to test an issue with `CropBox/MediaBox`, a reduced test-case should do just fine instead.

Please refer to issue 1155, and PR 1212.
2016-01-16 16:00:37 +01:00
Tim van der Meij
e54edd1128 Merge pull request #6883 from Snuffleupagus/issue-6854-10
Issue 6854 - Update the link locations to point to the Internet Archive for tests: issue2129, issue2139, issue2386, issue2442, issue2531
2016-01-16 14:49:52 +01:00
Jonas Jenwald
92fa439eac Remove 'tcpdf_033.pdf.link', since it has been replaced with a reduced test-case
In PR 1556 Brendan replaced the linked test, but apparently the `.link` file stuck around despite not being needed anymore.

Re: PR 6854.
2016-01-16 12:33:11 +01:00
Jonas Jenwald
2bdffdd7b0 Issue 6854 - Update the link locations to point to the Internet Archive for tests: issue2129, issue2139, issue2386, issue2442, issue2531 2016-01-16 12:10:48 +01:00
Jonas Jenwald
b7fe79c026 Merge pull request #6881 from timvandermeij/issue-6854-4
Update links to point to the Internet Archive for issue3384, issue3848, issue3903, issue3925 and issue5592
2016-01-16 12:02:33 +01:00
Jonas Jenwald
d52495a9c8 [TrueType] Recover from a missing "glyf" table by replacing it with dummy data, utilizing the existing code in sanitizeGlyphLocations
It seems to be fairly common for OCR software to include incomplete TrueType fonts, notable missing the "glyf" table, in PDF files. Since we currently reject such fonts, the result is that text-selection/copying is broken.

This patch contains a suggested approach to try and use these kind of broken fonts, by using existing code in `sanitizeGlyphLocations` to replace a missing "glyf" table with dummy data.

Fixes 4684.
Fixes 6007.
Fixes 6829.
2016-01-15 21:44:59 +01:00
Tim van der Meij
4155dfeb19 Update links to point to the Internet Archive for issue3384, issue3848, issue3903, issue3925 and issue5592 2016-01-15 21:44:59 +01:00
Tim van der Meij
159eb6d46c Update links to point to the Internet Archive for issue818, issue919, jai, liveprogramming and mao 2016-01-15 21:26:37 +01:00
Jonas Jenwald
223249fe2c Issue 6854 - Update the link locations to point to the Internet Archive for tests: issue1878, issue1912, issue1936, issue1998, issue2006 2016-01-15 18:22:03 +01:00
Tim van der Meij
7f821f5b78 Merge pull request #6876 from Snuffleupagus/issue-6854-8
Issue 6854 - Update the link locations to point to the Internet Archive for tests: issue1709, issue1721, issue1729, issue1796, issue1810
2016-01-15 16:38:45 +01:00
Jonas Jenwald
b03703f20c Issue 6854 - Update the link locations to point to the Internet Archive for tests: issue1709, issue1721, issue1729, issue1796, issue1810 2016-01-15 13:55:56 +01:00
Jonas Jenwald
93088ce342 Issue 6854 - Update the link locations to point to the Internet Archive for tests: issue1466, issue1629, issue1658, issue1685, issue1687 2016-01-15 13:30:24 +01:00
Tim van der Meij
5336a5363f Merge pull request #6871 from Snuffleupagus/issue-6854-6
Issue 6854 - Update the link locations to point to the Internet Archive for tests: issue1233, issue1257, issue1309, issue1317, issue1419
2016-01-15 01:04:40 +01:00
Tim van der Meij
8e58c8bc3d Merge pull request #6869 from Snuffleupagus/issue-6854-5
Issue 6854 - Update the link locations to point to the Internet Archive for tests: issue1049, issue1096, issue1127, issue1133, issue1169
2016-01-15 00:50:05 +01:00
Tim van der Meij
e6ff1a4179 Merge pull request #6866 from Snuffleupagus/issue-6854-4
Issue 6854 - Update the link locations to point to the Internet Archive for tests: html5checker, hudsonsurvey, ichiji, issue1010, issue1015
2016-01-15 00:24:06 +01:00
Tim van der Meij
04677eea45 Merge pull request #6867 from brendandahl/disable-e10s
Disable e10s.
2016-01-14 23:56:44 +01:00
Brendan Dahl
2d27cb1da6 Remove 'use strict'; causing failure and unused prefs. 2016-01-14 13:23:48 -08:00
Jonas Jenwald
01bb6b4e98 Issue 6854 - Update the link locations to point to the Internet Archive for tests: issue1233, issue1257, issue1309, issue1317, issue1419 2016-01-14 17:24:26 +01:00
Tim van der Meij
8318c8203c Merge pull request #6311 from yurydelendik/clean_test_manifest
Cleans test manifest from absent files.
2016-01-14 17:13:16 +01:00
Jonas Jenwald
850fa35040 Issue 6854 - Update the link locations to point to the Internet Archive for tests: issue1049, issue1096, issue1127, issue1133, issue1169 2016-01-14 12:06:30 +01:00
Jonas Jenwald
ff79c56fa3 Merge pull request #6865 from timvandermeij/hmm
Update the linked test case hmm.pdf to point to the intended version
2016-01-14 11:48:32 +01:00
Brendan Dahl
ad8e43a185 Disable e10s. 2016-01-13 15:21:28 -08:00
Jonas Jenwald
86f97d8e64 Issue 6854 - Update the link locations to point to the Internet Archive for tests: html5checker, hudsonsurvey, ichiji, issue1010, issue1015 2016-01-13 18:11:35 +01:00
Yury Delendik
18f0531619 Cleans test manifest from absent files. 2016-01-13 09:40:21 -06:00
Jonas Jenwald
38645f5701 Merge pull request #6864 from timvandermeij/issue6854-2
Update links to point to the Internet Archive for ohkubo-SS04, pal-o47, pdf, piperine and preistabelle
2016-01-13 16:33:35 +01:00
Tim van der Meij
17b639bfc5 Update the linked test case hmm.pdf to point to the intended version
The test case was changed in 1faca19021 because the original file was not available anymore. However, its hash was also changed, meaning that we do not test the intended version anymore.

This patch makes sure that we test the intented version by reverting to
the original hash and using a link, also pointing to the Internet
Archive, with the original file.
2016-01-13 16:30:26 +01:00
Yury Delendik
51b59bc86f Merge pull request #6853 from Snuffleupagus/issue-3666-test-link
Update the link location for 'issue3666.pdf' to point to the Internet Archive
2016-01-13 08:49:40 -06:00
Tim van der Meij
c6ad1b573b Update links to point to the Internet Archive for ohkubo-SS04, pal-o47, pdf, piperine and preistabelle 2016-01-13 14:59:21 +01:00
Jonas Jenwald
239846f0d6 Issue 6854 - Update the link locations to point to the Internet Archive for tests: cable, fips197, fit11-talk, geothermal, hmm 2016-01-12 21:35:23 +01:00
Tim van der Meij
7e2f1f43e4 Merge pull request #6860 from Snuffleupagus/issue-6854-2
Issue 6854 - Update the link locations to point to the Internet Archive for tests: artofwar, bpl13210, bug766138, bug808084, bug887152
2016-01-12 16:34:00 +01:00
Jonas Jenwald
a20883ac79 Issue 6854 - Update the link locations to point to the Internet Archive for tests: artofwar, bpl13210, bug766138, bug808084, bug887152 2016-01-12 15:51:39 +01:00
Tim van der Meij
3df2b1141c Update five linked test cases to point to the Internet Archive 2016-01-12 15:00:36 +01:00
Jonas Jenwald
15e384c558 Issue 6854 - Re-enable testing of 'aboutstacks.pdf'
This test was disabled in PR 4732, because the file was no longer available. The motivation being that there were two other files which should be good replacements. However, one of those has since been replaced with a reduced test-case (which doesn't exercise the same code-path), and in the other one the error does not appear to be entirely identical.
Hence it seems reasonable to re-add the 'aboutstacks.pdf' test, since it was possible to find it on the Internet Archive (by searching using a different URL, compared to the current one).
2016-01-12 13:13:43 +01:00
Jonas Jenwald
57097c54de Issue 6854 - Update the link locations to point to the Internet Archive for tests: 20130226130259, JST2007-5, P020121130574743273239, SFAA_Japanese, TaroUTR50SortedList112 2016-01-11 23:47:24 +01:00
Jonas Jenwald
c197e47742 Update the link location for 'issue3666.pdf' to point to the Internet Archive
Note that despite the new file having a different hash than the the current one, it does render *identically* and most importantly it uses *the same* JBIG2 functionality.

For reference, please see issue 3666 and PR 3738.
2016-01-11 21:27:00 +01:00
Brendan Dahl
3057b69e45 Merge pull request #6839 from Snuffleupagus/issue-6782
Check that CIDFontType0 fonts does not actually contain OpenType font files (issue 6782)
2016-01-11 08:56:48 -08:00
Tim van der Meij
30b8f41003 Merge pull request #6820 from Snuffleupagus/showText-shadingPattern
Apply Patterns, if necessary, when rendering text
2016-01-08 14:02:56 +01:00
Daan Sprenkels
90ec2c9294 shading-pattern: Decreased Shadings.SMALL_NUMBER
and added a test case for #6298
2016-01-06 15:26:40 +01:00
Jonas Jenwald
325abf5f8c Update the link location for 'intelisa.pdf' to point to the Internet Archive
Given the the file changes every now and then, this patch should ensure that we test the *intended* version.
2016-01-06 12:56:31 +01:00
Jonas Jenwald
896e390285 Check that CIDFontType0 fonts does not actually contain OpenType font files (issue 6782)
*This patch follows a similar idea as PR 5756.*

The patch is based on the nice debugging done by Brendan in the referenced issue 6782.
A better way to handle this, and similar issues, would probably be to completely ignore what the PDF file claims about font type/subtype, and just check the actual data. But until that kind of rewrite happens, this patch should help.

Fixes 6782.
2016-01-06 02:19:02 +01:00
Tim van der Meij
4399d01169 Merge pull request #6834 from Snuffleupagus/issue-6832
Strip `null` (\x00) characters from the URLs in LinkAnnotations (issue 6832)
2016-01-05 23:59:25 +01:00
Jonas Jenwald
0083f63dda Fix a typo in the "file" entry for issue3694_reduced in test_manifest.json
When generating new references locally on Windows, after PR 6724, I get the following output:
```
WARNING: Unable to open file for reading "Error: ENOENT, open 'c:\Users\Jonas\Git\pdfjs\test\pdfs\issue_3694_reduced.pdf'".
Unable to verify the checksum for the files that are used for testing.
Please re-download the files, or adjust the MD5 checksum in the manifest for the files listed above.

```

Compared to the name of the file (`issue3694_reduced.pdf`), you see that the manifest entry has a superfluous underscore in the "file" entry.
2016-01-05 21:23:00 +01:00
Brendan Dahl
eb7c36beb6 Add validation for callsubr and callgsubr for type 2 charstrings. 2016-01-05 09:54:25 -08:00
Jonas Jenwald
97c10e9c08 Strip null (\x00) characters from the URLs in LinkAnnotations (issue 6832)
Apparently some PDF files can have annotations with `URI` entries ending with `null` characters, thus breaking the links.
To handle this edge-case of bad PDFs, this patch moves the already existing utility function from `ui_utils.js` into `util.js`, in order to fix those URLs.

Fixes 6832.
2016-01-04 21:55:20 +01:00
Tim van der Meij
6ef7120a04 Implement support for Highlight annotations 2016-01-01 15:31:46 +01:00
Tim van der Meij
34918a6666 Implement support for Squiggly annotations 2015-12-30 19:37:04 +01:00
Jonas Jenwald
d956177482 Merge pull request #6819 from timvandermeij/strikeout-annotation
Implement support for StrikeOut annotations
2015-12-30 14:44:50 +01:00
Tim van der Meij
e8db825512 Merge pull request #6771 from yurydelendik/requirejs
Removes hardcoded module loading order
2015-12-30 00:37:32 +01:00
Yury Delendik
b8e7efaaa1 Merge pull request #6821 from yurydelendik/bug951051
Bug 951051 - Better crypto key length recovery.
2015-12-29 15:35:15 -06:00
Yury Delendik
c991480687 Better crypto key length recovery. 2015-12-29 15:10:38 -06:00
Jonas Jenwald
1d1f175826 Apply Patterns, if necessary, when rendering text
Currently we're not applying Patterns for text, but only for graphics.

This patch is unfortunately not a complete solution, but rather a step on the way, since there are still some PDF files where the Patterns look more like a solid colour, rather than the intended gradient.
I've been unable to fix these issues completely, and I've not managed to determine if the remaining issues are caused either by the pattern code, the canvas code, or perhaps both.

However, given that even this simple patch improves the current situation quite a bit, I figured that it couldn't hurt to submit it as-is.

 - Fixes 5804.
 - Fixes 6130.
 - Improves 3988 a lot, since the text is now visible. However, it looks like the text is *one* solid colour, instead of the correct gradient.
 - Improves 5432, since the text is no longer gray. (This file also suffers from the same problem as the previous one.)
2015-12-29 20:02:40 +01:00
Yury Delendik
85e95d34ed Use RequireJS in the viewer, examples and tests. 2015-12-29 09:20:52 -06:00
Tim van der Meij
c5f4b9750e Implement support for StrikeOut annotations 2015-12-29 15:09:28 +01:00
Jonas Jenwald
b32cdf5836 Merge pull request #6813 from timvandermeij/underline-annotation
Implement support for Underline annotations
2015-12-28 23:48:31 +01:00
Jonas Jenwald
85589483d6 Merge pull request #6807 from timvandermeij/popup-annotation-hidden
Ensure that hidden popups do not use any space
2015-12-28 22:58:41 +01:00
Tim van der Meij
ae329afc03 Ensure that hidden popups do not use any space 2015-12-28 18:54:10 +01:00
Tim van der Meij
edf8ccc1d8 Merge pull request #6814 from Snuffleupagus/beginAnnotations-baseTransform
Ensure that the `baseTransform` is applied when rendering annotations
2015-12-28 18:32:50 +01:00
Jonas Jenwald
2f2ea6160b Ensure that the baseTransform is applied when rendering annotations
Fixes 3350.
Fixes 5946.
Fixes 6334.
Fixes 6722.
Probably fixes 3826 (since the PDF files are no longer available, I cannot confirm it).
2015-12-28 16:02:38 +01:00
Tim van der Meij
cd28dd34fe Implement support for Underline annotations 2015-12-28 00:33:41 +01:00
Tim van der Meij
26379ddae2 Rename and reorder link annotation CSS 2015-12-27 15:51:58 +01:00
Tim van der Meij
7d43971f54 Implement support for Popup annotations
Most code for Popup annotations is already present for Text annotations.
This patch extracts the popup creation logic from the Text annotation
code so it can be reused for Popup annotations.

Not only does this add support for Popup annotations, the Text
annotation code is also considerably easier. If a `Popup` entry is
available for a Text annotation, it will not be more than an image. The
popup will be handled by the Popup annotation. However, it is also
possible for Text annotations to not have a separate Popup annotation,
in which case the Text annotation handles the popup creation itself.
2015-12-25 13:17:21 +01:00
Jonas Jenwald
ae4ec2e347 Change test-case issue4914 to an annotations test
This PDF file (see issue 4914) originally regressed in PR 4318, and was subsequently fixed in PR 4915.

I added the PDF file as a (linked) test-case in PR 6481, in an effort to prevent regressions. Since we at that time didn't have the necessary framework in place, in order to correctly test annotations, this almost regressed *again* in PR https://github.com/mozilla/pdf.js/pull/6672#issuecomment-158689392.

In that PDF file, some of the annotations are both printable and hidden, and should definitely *not* be visible on normal display. Hence this patch, which adds the `annotations` flag to the manifest in order to ensure that those annotations won't be rendered when `intent === 'display'`.
2015-12-21 15:41:18 +01:00
Tim van der Meij
b7217a2274 Implement annotation layer regression testing 2015-12-20 13:45:56 +01:00
Yury Delendik
6b60c8f4db Adds UMD headers to core, display and shared files. 2015-12-15 13:24:39 -06:00
Tim van der Meij
1b5940edd2 Merge pull request #6714 from timvandermeij/annotation-web-to-src
[api-minor] Move annotation DOM manipulation logic to src/display/annotation_layer.js
2015-12-15 19:06:48 +01:00
Tim van der Meij
f93a220736 Merge pull request #6684 from dsprenkels/issue-6296-radial-shading-size
shading-pattern: While drawing patterns, use transform to baseTransform first
2015-12-14 20:39:08 +01:00
Jonas Jenwald
ee0d522187 Use adjustWidths for TrueType fonts if we handle them as OpenType (issue 5027, issue 5084, issue 6556, bug 1204903)
In `Font_checkAndRepair` we can decide that a font isn't TrueType, and instead parse it as CFF. In that case it's quite possible that the `fontMatrix` will be changed, and without calling `adjustWidths` we're failing to update the glyph widths correctly.

Fixes 5027.
Fixes 5084.
Fixes 6556.
Fixes https://bugzilla.mozilla.org/show_bug.cgi?id=1204903.
2015-12-08 00:49:22 +01:00
Jonas Jenwald
084bb8682f Merge pull request #6723 from yurydelendik/smask-transfer
Adds transfer function support for SMask.
2015-12-05 22:41:56 +01:00
Yury Delendik
1bbe8f3fee Replaces test for #6720 to fix botio-linux slow script. 2015-12-05 12:33:25 -06:00
Jonas Jenwald
4810b7b8fc Fix the charCodeOf method in IdentityToUnicodeMap in order to prevent text selection from breaking
After PR 6590, `font.spaceWidth` is now called in more cases than before (in `PartialEvaluator_getTextContent`), which exposed an underlying issue with `IdentityToUnicodeMap_charCodeOf` throwing an error.
This breaks text-selection in some PDF files found in the wild, hence this patch replaces the `error` with an actual function instead (modelled after `IdentityCMap_charCodeOf`).
2015-12-05 13:15:55 +01:00
Yury Delendik
15c9969abe Adds transfer function support for SMask. 2015-12-04 12:52:45 -06:00
Jonas Jenwald
e2aca385c6 Merge pull request #6720 from yurydelendik/smask-state
Fixes canvas state after smask group ends.
2015-12-03 22:19:37 +01:00
Yury Delendik
d4843ebf6d Fixes canvas state after smask group ends. 2015-12-03 14:34:12 -06:00
Brendan Dahl
87762afec4 Remove glyph id's outside the range of valid glyphs.
OTS does not like invalid glyph ids in a camp table.
2015-12-03 11:53:06 -08:00
Tim van der Meij
91274d6d2d Rename annotation_helper.js to annotation_layer.js 2015-12-02 23:30:28 +01:00
Daan Sprenkels
a9081653fc shading-pattern: While drawing patterns, transform to the baseTransform first 2015-12-02 21:49:38 +01:00
Jonas Jenwald
995e1a45b8 Ensure that Lexer_getName does not fail if a Name contains in invalid usage of the NUMBER SIGN (#) (issue 6692)
*This is a regression from PR 3424.*

The PDF file in the referenced issue is using `Type3` fonts. In one of those, the `/CharProcs` dictionary contains an entry with the name `/#`. Before the changes to `Lexer_getName` in PR 3424, we were allowing certain invalid `Name` patterns containing the NUMBER SIGN (#).

It's unfortunate that this has been broken for close to two and a half years before the bug surfaced, but it should at least indicate that this is not a widespread issue.

Fixes 6692.
2015-11-28 11:59:09 +01:00
Tim van der Meij
5fcd779812 Merge pull request #6209 from Rob--W/parallel-rendering
Fix font rendering when rendering multiple PDFs in parallel
2015-11-25 22:51:15 +01:00
Jonas Jenwald
6dfe53b976 [api-minor] Add a parameter to PDFPageProxy_getTextContent that enables replacing of all whitespace with standard spaces in the textLayer (issue 6612)
This patch goes a bit further than issue 6612 requires, and replaces all kinds of whitespace with standard spaces.

When testing this locally, it actually seemed to slightly improve two existing test-cases (`tracemonkey-text` and `taro-text`).

Fixes 6612.
2015-11-25 17:28:40 +01:00
Rob Wu
07f2a43943 Add tests for parallel rendering 2015-11-25 17:22:51 +01:00
Yury Delendik
09772e1e15 Creates PDFWorker, separates fetchDocument from transport. 2015-11-24 13:27:22 -06:00
Jonas Jenwald
b05652ca97 [api-minor] Let getAnnotations fetch all annotations by default, unless an intent is specified
Currently `getAnnotations` will *only* fetch annotations that are either `viewable` or `printable`. This is "hidden" inside the `core.js` file, meaning that API consumers might be confused as to why they are not recieving *all* the annotations present for a page.

I thus think that the API should, by default, return *all* available annotations unless specifically told otherwise. In e.g. the default viewer, we obviously only want to display annotations that are `viewable`, hence this patch adds an `intent` parameter to `getAnnotations` that makes it possible to decide if only `viewable` or `printable` annotations should be fetched.
2015-11-22 15:51:37 +01:00
Tim van der Meij
0991c06395 Refactor annotation flags code
This patch makes it possible to set and get all possible flags that the PDF specification defines. Even though we do not support all possible annotation types and not all possible annotation flags yet, this general framework makes it easy to access all flags for each annotation such that annotation type implementations can use this information.

We add constants for all possible annotation flags such that we do not need to hardcode the flags in the code anymore. The `isViewable()` and `isPrintable()` methods are now easier to read. Additionally, unit tests have been added to ensure correct behavior.

This is another part of #5218.
2015-11-22 01:06:37 +01:00
Yury Delendik
bd7f121c83 Better "text" testing. 2015-11-19 11:03:52 -06:00
Yury Delendik
56ccaea99b Move text layer building logic into src/display/text_layer.js 2015-11-19 10:50:27 -06:00
Yury Delendik
2f34fd46cb Move CustomStyle. 2015-11-19 10:47:17 -06:00
Jonas Jenwald
055573fc83 Replace the unavailable linked test-case for issue 1055 with a reduced test-case
Re: issue 1055 and PR 1095.
2015-11-18 13:48:44 +01:00
Yury Delendik
194994a289 Merge pull request #6551 from yurydelendik/subaa
[api-minor] Enables subpixel anti-aliasing for most of the content.
2015-11-17 19:45:32 -06:00
Yury Delendik
2f1a626d6a Merge pull request #6640 from dsprenkels/issue-6006-radial-gradient-size
Apply transformation matrix to RadialGradient radiuses
2015-11-17 11:40:13 -06:00
Daan Sprenkels
6ce83d3290 apply transformation matrix to RadialGradient radiuses,
not only to circle origin points
fix for #6006
2015-11-17 00:20:42 +01:00
Jonas Jenwald
bd8d3a78a3 Replace the unavailable linked test-case for issue 845 with a reduced test-case
Re: issue 845 and PR 1977.
2015-11-16 23:38:23 +01:00
Yury Delendik
99f9b523c2 Merge pull request #6627 from prometheansacrifice/use-editorconfig
Uses editorconfig to maintain consistent coding styles
2015-11-16 13:51:45 -06:00
Yury Delendik
37f511cb65 Merge pull request #6645 from Snuffleupagus/issue-3405-reduced-test
Replace the unavailable linked test-case for issue 3405 with a reduced test-case
2015-11-16 11:37:41 -06:00
Yury Delendik
c506ca6ba1 Merge pull request #6642 from Snuffleupagus/pr-2606-reduced-tests
Replace the unavailable linked test-cases for PR 2606 with reduced test-cases
2015-11-16 11:29:52 -06:00
Yury Delendik
b2e3c59372 Merge pull request #6639 from Snuffleupagus/pr-197-reduced-test
Replace the unavailable linked test-case for PR 197 with a reduced test-case
2015-11-16 11:27:10 -06:00
Yury Delendik
1d8800370a Allow subpixel anti-aliasing for most of the content. 2015-11-16 10:50:02 -06:00
Jonas Jenwald
1478241c8e Replace the unavailable linked test-case for issue 3405 with a reduced test-case
Re: issue 3405 and PR 3861.
2015-11-16 17:06:53 +01:00
Jonas Jenwald
841831f35e Replace the unavailable linked test-cases for PR 2606 with reduced test-cases
Re: PR 2606.
2015-11-16 13:15:36 +01:00
Jonas Jenwald
4b360512af Replace the unavailable linked test-case for PR 197 with a reduced test-case
Re: PR 197.

*Note:* Since this is a `load` test, `makeref` won't be necessary.
2015-11-15 20:07:54 +01:00
Jonas Jenwald
dca681e82b Replace the unavailable linked test-case for issue 1655 with a reduced test-case
Re: issue 1655 and PR 1978.
2015-11-15 15:32:11 +01:00
Jonas Jenwald
458aff66f4 Replace the unavailable linked test-case for issue 3207 with a reduced test-case
Re: issue 3207 and PR 3268.
2015-11-15 13:33:36 +01:00
Manas
a2ba1b8189 Uses editorconfig to maintain consistent coding styles
Removes the following as they unnecessary
/* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set shiftwidth=2 tabstop=2 autoindent cindent expandtab: */
2015-11-14 07:32:18 +05:30
Jonas Jenwald
5bd76c46ac Replace the unavailable linked test-case for issue 3263 with a reduced test-case
Re: issue 3263 and PR 3265.
2015-11-13 16:47:02 +01:00
Jonas Jenwald
50a70429ec Ignore the /Mask entry in images unless its /ImageMask entry is explicitly set to true (issue 6621)
Fixes 6621.
2015-11-12 22:49:26 +01:00
Tim van der Meij
3a23367f04 Merge pull request #6610 from Snuffleupagus/issue-2128-reduced-test
Replace the unavailable linked test-case for issue 2128 with a reduced test-case
2015-11-11 23:02:29 +01:00
Tim van der Meij
d8ddde26b7 Merge pull request #6622 from yurydelendik/rm-mc-tests
Remove mozcentral test files.
2015-11-11 22:57:40 +01:00
Yury Delendik
4c9f6741ae Remove mozcentral test files. 2015-11-11 15:54:17 -06:00
Yury Delendik
248e211a20 Merge pull request #6600 from Rob--W/test-server-improved
Improve reliability of the test server
2015-11-11 13:50:25 -06:00
Rob Wu
b0ff49e456 Improve reliability of the test server
- replace // with /
  (otherwise http://localhost:8888// links to e.g. http://src/ instead
   of http://localhost:8888/src).

- Solve XSS issue (file names should be sanitized, not output as-is).

- Prevent server from crashing if there is a stat error (e.g. permission
  error or file not found (e.g. broken symlink)).
2015-11-11 18:37:29 +01:00
Jonas Jenwald
3008580972 Replace the unavailable linked test-case for issue 2128 with a reduced test-case
Re: issue 2128 and PR 2628.
2015-11-11 12:49:42 +01:00
Yury Delendik
3674f0d7c7 Merge pull request #6620 from Rob--W/node-test-random-port
Use random port in test webserver
2015-11-10 13:13:01 -06:00
Rob Wu
ff8c334207 Use random port in test webserver 2015-11-10 19:10:23 +01:00
Jonas Jenwald
ff64ef0243 Prevent readCmapTable from failing if the cmap is missing in TrueType fonts
Fixes http://arrow.dit.ie/cgi/viewcontent.cgi?article=1000&context=aaschadpoth#page=3.
2015-11-08 16:48:37 +01:00
Jonas Jenwald
66c17a69ae Add a reduced text test-case for issue 4665
Re: issue 4665 and PR 6601.

Since we currently don't have a good `text` test-case that fails without the above PR, this patch adds a reduced one.
2015-11-07 13:09:08 +01:00
Yury Delendik
4ee0bade82 Test for text layer issue 1045. 2015-11-06 10:55:43 -06:00
Yury Delendik
7e8dacf57b Merge pull request #6588 from yurydelendik/spacing
Better spacing in text layer.
2015-11-03 09:24:43 -06:00
Yury Delendik
27efe5608f Test case from #6019. 2015-11-03 09:03:08 -06:00
Jonas Jenwald
034087bb40 Replace the linked test-case for issue 3879 with a reduced test-case
Re: issue 3879 and PR 3880.
2015-11-01 13:02:10 +01:00
Jonas Jenwald
cf09f38340 Replace the linked test-case for issue 1293 with a reduced test-case
When I submitted PR 3576, I included a linked test-case. The reason was that I didn't know enough about the PDF format, in order to successfully create a reduced test-case.
Considering that the link points to a Dropbox, there's no guarantee that the PDF file will remain available, hence it seems worthwhile to replace the test-case.

*Note:* Since this is a `load` test, `makeref` won't be necessary.
2015-10-29 13:39:29 +01:00
Jonas Jenwald
1c66d4a106 Add a totalLength getter to OperatorList, since the length is zero after flushing
In the `RenderPageRequest` handler in `worker.js`, we attempt to print an `info` message containing the rendering time and the length of the operator list. The latter is currently broken (and has been for quite some time), since the `length` of an `OperatorList` is reset when flushing occurs.
This patch attempts to rectify this, by adding a getter which keeps track of the total length.
2015-10-26 18:12:14 +01:00
Jonas Jenwald
25e55322c4 Improved get fingerprint unit-tests (PR 5124)
This patch adds a unit-test for the changes contained in PR 5124, and also improves the existing `get fingerprint` test slightly.
2015-10-24 14:18:36 +02:00
Yury Delendik
5111422d89 Merge pull request #6558 from Snuffleupagus/issue-6151-test
Add a reduced test-case for issue 6151
2015-10-23 14:45:57 -05:00
Brendan Dahl
2a5616c2aa Merge pull request #6546 from yurydelendik/destroy
[api-minor] Adds controlled destruction of the worker.
2015-10-23 10:54:01 -07:00
Jonas Jenwald
ec04c4acb7 Add a reduced test-case for issue 6151
Re: issue 6151 and PR 6193.

*Note:* Since this is a `load` test, `makeref` won't be necessary.
2015-10-23 18:50:14 +02:00
Yury Delendik
58c3ea0820 Adds thread abort capabilities. 2015-10-23 09:06:32 -05:00
Yury Delendik
59c13b32aa Adds destroy method to the document loading task.
Also renames PDFPageProxy.destroy method to cleanup.
2015-10-23 08:57:14 -05:00
Jonas Jenwald
d3782ff8d4 Add a reduced test-case for issue 4575
Re: issue 4575 and PR 4581.
2015-10-23 15:15:06 +02:00
Jonas Jenwald
2e751199fb Prevent getOperatorList from failing to correctly parse OPS.paintXObject for TilingPatterns that are missing some /Resources entries (issue 6541)
Fixes 6541.
2015-10-21 21:30:56 +02:00
Jonas Jenwald
e04113a35b Add unit-tests for the onPassword/onProgress callbacks of the API
The standard viewer implicitly depends on the `onPassword` and `onProgress` callbacks, in order to open password protected PDF files, respectively to report file loading progress. We currently have no unit-tests for this functionality, which seems unfortunate; hence this patch.

*Please note:* Rather than adding more unit-tests to `api_spec.js`, I slightly extended/reworked two existing tests. Specifically for the password test, this *does not* really change what we actually test, just how the test is done.
2015-10-21 00:01:52 +02:00
Jonas Jenwald
5987197bd5 Ensure that all getDocument unit-tests returns the expected data 2015-10-16 18:54:20 +02:00
Jonas Jenwald
34cbee9bd3 Add unit-tests for PR 6531 2015-10-16 18:54:18 +02:00
Jonas Jenwald
39b962e3b0 Add unit-tests for isExternalLinkTargetSet 2015-10-13 21:56:46 +02:00
Tim van der Meij
d89fde05b0 Merge pull request #6481 from Snuffleupagus/issue-4914-test
Add a (linked) test-case for issue 4914
2015-10-13 20:02:48 +02:00
Tim van der Meij
c4403e6fd2 Merge pull request #6434 from Snuffleupagus/issue-4436-reduced-test
Replace the unavailable linked test-case for issue 4436 with a reduced test-case
2015-10-13 00:32:05 +02:00
Brendan Dahl
3eaeacfe19 Merge pull request #6476 from Snuffleupagus/PartialEvaluator_readToUnicode-cmap-length
Right-size the `map` array in PartialEvaluator_readToUnicode
2015-10-09 10:31:28 -07:00
Jonas Jenwald
03f2c704a3 Add a reduced load test-case for bug 1020858
Re: PR 4907 and https://bugzilla.mozilla.org/show_bug.cgi?id=1020858.

*Note:* Since this is a `load` test, `makeref` won't be necessary.
2015-10-04 23:49:49 +02:00
Tim van der Meij
cd8bd73529 Merge pull request #6499 from Snuffleupagus/issue-4387-test
Add a (linked) load test for issue 4387
2015-10-04 16:50:18 +02:00
Tim van der Meij
1e29ddc4de Merge pull request #6500 from Snuffleupagus/pr-4897-test
Add a (linked) test-case for PR 4897
2015-10-04 16:26:57 +02:00
Tim van der Meij
5e4910f7b6 Merge pull request #6491 from Snuffleupagus/check-trailer-if-xref-missing
Make `XRef_indexObjects` even more robust against bad PDF files, by checking for the existence of 'trailer' if 'xref' is not found
2015-10-04 16:00:00 +02:00
Jonas Jenwald
e8ad6c9d13 Add a unit-test for bug 1020226
For reference, see PR 4902 and https://bugzilla.mozilla.org/show_bug.cgi?id=1020226.
2015-10-04 15:45:24 +02:00
Jonas Jenwald
ae255f8921 Slightly improved getPage unit-tests 2015-10-04 14:28:24 +02:00
Jonas Jenwald
bdfda37c04 Add a (linked) test-case for PR 4897
Re: PR 4897.
2015-10-04 13:54:05 +02:00
Jonas Jenwald
96b3dc127d Add a (linked) load test for issue 4387
Re: PR 4404 and issue 4387.
2015-10-04 13:15:10 +02:00
Jonas Jenwald
192907e0d2 Make XRef_indexObjects even more robust against bad PDF files, by checking for the existence of 'trailer' if 'xref' is not found
Fixes http://www.cyjack.com/cognition/Terence%20McKenna%20-%20Lectures%20on%20Alchemy.pdf.
2015-10-01 15:01:25 +02:00
Jonas Jenwald
1b8cb52555 Prevent PartialEvaluator_buildFormXObject from failing if the Matrix or BBox contains indirect objects
This patch fixes yet another instance of bad PDF data, specifically a case where the `BBox` array contains indirect objects (i.e. `Ref`s).

Fixes the missing image in http://www.int.washington.edu/talks/WorkShops/int_08_37W/People/Franz_M/Franz.pdf#page=24. *Note:* There are missing images on a number of the pages in that file.
2015-09-29 10:11:49 +02:00
Tim van der Meij
973b15c5de Merge pull request #6482 from Snuffleupagus/TilingPattern-baseTransform
Ensure that the `baseTransform` is always defined for TilingPatterns
2015-09-29 00:27:39 +02:00
Tim van der Meij
a6270bb449 Merge pull request #6452 from Snuffleupagus/pr-2875-reduced-test
Replace the unavailable linked test-case for PR 2875 with a reduced test-case
2015-09-29 00:04:16 +02:00
Tim van der Meij
67ed161a6a Merge pull request #6450 from Snuffleupagus/issue-3115-test-new-link
Update the link location for the `issue3115` test file
2015-09-28 23:35:29 +02:00
Jonas Jenwald
9eab463b6d Ensure that the baseTransform is always defined for TilingPatterns
Fixes http://www2.emersonprocess.com/siteadmincenter/PM%20Micro%20Motion%20Documents/High-Pressure-Measurement-WP-001287.pdf#page=3.
2015-09-27 22:49:34 +02:00
Jonas Jenwald
427d0f982d Add a (linked) test-case for issue 4914 2015-09-26 16:09:10 +02:00
Jonas Jenwald
8d831449ab Right-size the map array in PartialEvaluator_readToUnicode
We can avoid a lot of intermediate resizings, by directly allocating the required number of elements for the `map` array.
2015-09-24 13:08:53 +02:00
Jonas Jenwald
b218b222b5 Replace the unavailable linked test-case for PR 2875 with a reduced test-case
This reduced PDF file only contains the relevant text/font; for reference please see PR 2875.
2015-09-16 13:59:58 +02:00
Jonas Jenwald
958fb71ef4 Update the link location for the issue3115 test file
The file (`lshort.pdf`) has changed a couple of times since the test was added, hence there's no guarantee that the current version accurately reflects the issues the test was added to check.
In this patch, I'm updating the link location to point to the *intended* file version (hosted on the "Internet Archive").
2015-09-15 15:17:07 +02:00
Fabian Lange
2564827503 Fix text spacing with vertical fonts (#6387)
According to the PDF spec 5.3.2, a positive value means in horizontal,
that the next glyph is further to the left (so narrower), and in
vertical that it is further down (so wider).
This change fixes the way PDF.js has interpreted the value.
2015-09-15 09:28:45 +02:00
Tim van der Meij
e68a5c0222 Merge pull request #6435 from Snuffleupagus/issue-3205-reduced-test
Replace the unavailable linked test-case for issue 3205 with a reduced test-case
2015-09-14 23:59:14 +02:00
Jonas Jenwald
297984e2e9 Add unit-tests for removeNullCharacters (PR 6431 follow-up)
I overlooked that we already had existing unit-tests for `web/ui_utils.js`, so this PR adds a few tests for `removeNullCharacters` (see PR 6431).
2015-09-14 12:19:29 +02:00
Tim van der Meij
b360fd104b Merge pull request #6420 from Snuffleupagus/pr-4922-test
Add a reduced test-case for PR 4922
2015-09-10 21:54:45 +02:00
Jonas Jenwald
c043a6e3a3 Replace the unavailable linked test-case for issue 3205 with a reduced test-case 2015-09-10 16:59:30 +02:00
Jonas Jenwald
7f7025247a Replace the unavailable linked test-case for issue 4436 with a reduced test-case
Issue 4436 actually contains enough information to create a reduced test-case, which this patch uses to replace a currently unavailable linked test.
2015-09-10 13:01:20 +02:00
Jonas Jenwald
c5c8b239e9 Add unit-tests for stringToPDFString
The other day I was looking as the utilily function `stringToPDFString`, and I noticed that it didn't have any unit-tests. This patch fixes that.
2015-09-10 12:25:40 +02:00
Jonas Jenwald
29a1cdb6a6 Only choose a (3, 1) cmap table for TrueType fonts that have an encoding specified (issue 6410)
For (1, 0) cmaps, we have two different codepaths depending on whether the font has/hasn't got an encoding. But with (3, 1) cmaps we don't have a good fallback when the encoding is missing, hence this patch changes `readCmapTable` to only choose a (3, 1) cmap table if the font is non-symbolic *and* an encoding exists. Without this, we'll not be able to successfully create a working glyph map for some TrueType fonts with (3, 1) cmap tables.

Fixes 6410.
2015-09-07 16:56:05 +02:00
Jonas Jenwald
de6a74f58d Add a reduced test-case for PR 4922 2015-09-05 12:51:05 +02:00
Brendan Dahl
238e16feeb Merge pull request #6407 from Snuffleupagus/bug-1200096
Fallback in `readCmapTable`, instead of using `error`, for TrueType fonts with unsupported cmap formats (bug 1200096)
2015-09-04 18:10:34 -07:00
Tim van der Meij
2a0e0787c3 Merge pull request #6414 from Snuffleupagus/issue-6413
Ensure that the clipping path is reset when the state is restored (issue 6413)
2015-09-04 17:53:16 +02:00
Jonas Jenwald
e16fc486a4 Add (linked) ´load` tests for PR 1976 and 4606
Adds a couple of `load` tests for the `XRef` parsing part of the code-base, see PR 1976 and 4606.
2015-09-04 13:19:32 +02:00
Jonas Jenwald
b4ade44ab9 Add a reduced test-case for issue 6413 2015-09-03 22:29:12 +02:00
Jonas Jenwald
0fb31a4a9e Fallback in readCmapTable, instead of using error, for TrueType fonts with unsupported cmap formats (bug 1200096)
Fixes https://bugzilla.mozilla.org/show_bug.cgi?id=1200096.

The problematic font has a `format 2` cmap, which we've never supported properly. Prior to PR 2606, we were able to fallback to a working state, despite not having proper support for that cmap format.

Obviously the best/correct solution would be to implement actual support for more cmap formats[1]. However, I'm hoping that a simple patch will be OK for now, given that:
 - `format 2` cmaps seem to be quite rare in practice, since this has been broken for 2.5 years before anyone noticed.
 - Having a simple patch will make potential uplifts a lot easier.

[1] See the specification at https://developer.apple.com/fonts/TrueType-Reference-Manual/RM06/Chap6cmap.html
2015-09-01 14:01:19 +02:00
Jonas Jenwald
09b825d1be Add a (linked) load test for PR 4731
Re: PR 4731.
Since the URL points to the Internet Archive, I think that adding a linked test-case should be OK. (Also, it's difficult to create reduced, or even `unit`, tests that accurately captures the brokenness of real-world PDF files.)

*Please note:* Since this is a `load` test, `makeref`ing won't be needed.
2015-08-31 17:15:41 +02:00
Tim van der Meij
678b662720 Merge pull request #6399 from Snuffleupagus/vertical-text-taro
Slightly improved test coverage for vertical text
2015-08-31 16:27:21 +02:00
Tim van der Meij
61459c7e30 Merge pull request #6403 from Snuffleupagus/issue-6113-test
Add a reduced test-case for issue 6113
2015-08-31 15:51:47 +02:00
Yury Delendik
943efea876 Merge pull request #6404 from Snuffleupagus/linearization-unit-tests
Add unit-tests for Linearization dictionary parsing (PR 5023 follow-up)
2015-08-31 07:38:55 -05:00
Tim van der Meij
f518bbcc7c Merge pull request #6401 from Snuffleupagus/paintXObject-subtype-PS-unit-test
Add a unit-test for skipping `paintXObject` if `Subtype === PS` (PR 4861)
2015-08-30 23:03:32 +02:00
Jonas Jenwald
0edb520a10 Add unit-tests for Linearization dictionary parsing (PR 5023 follow-up)
This should *really* have been part of 5023, but better late than never I suppose.
2015-08-30 14:06:11 +02:00
Jonas Jenwald
ba9fcce8eb Add a reduced test-case for issue 6113
As promised in PR 6125, here's a reduced test-case that should (hopefully) avoid the intermittent failure of the previous one.
2015-08-30 01:23:52 +02:00
Jonas Jenwald
0dde08554d Add a unit-test for skipping paintXObject if Subtype === PS (PR 4861) 2015-08-29 20:43:22 +02:00
Jonas Jenwald
3ae49e15b3 Slightly improved test coverage for vertical text
Our current test coverage for vertical text is somewhat lacking, as evident from e.g. issue 6387. That regression could easily have been avoided if the `taro` test-case would have been an `eq` test, as well as an `text` test.
2015-08-29 15:54:32 +02:00
Jonas Jenwald
593ea00ecb Fix typo in test_manifest.json that prevents test-case issue1419.pdf from running
Currently we only attempt to test the *first* page, since `lastPage == 1`, but given that it's subsequently skipped we end up not testing anything.

*Note:* I've verified that the *second* page actually contains the kind of Colour space that the test was intended to check for.
2015-08-28 16:35:10 +02:00
Brendan Dahl
88e0326787 Merge pull request #6337 from Snuffleupagus/issue-6336
Adjust which TrueType (3, 1) glyphs we attempt to skip mapping of (issue 6336)
2015-08-25 09:49:46 -07:00
Jonas Jenwald
56a43a3181 Make XRef_indexObjects more robust against bad PDF files (issue 5752)
This patch improves the detection of `xref` in files where it is followed by an arbitrary whitespace character (not just a line-breaking char).
It also adds a check for missing whitespace, e.g. `1 0 obj<<`, to speed up `readToken` for the PDF file in the referenced issue.
Finally, the patch also replaces a bunch of magic numbers with suitably named constants.

Fixes 5752.

Also improves 6243, but there are still issues.
2015-08-21 20:33:02 +02:00
Jonas Jenwald
5128603f64 Also check maybeLength when deciding if a stream is empty in Parser_makeFilter (issue 6360)
The problem with the PDF files in the issue, besides the obviously broken XRef tables which we're able to recover from, is that many/most of the streams have Dictionaries where the `Length` entry is set to `0`. This causes us to return `NullStream`, instead of the appropriate one in `Parser_makeFilter`.

Fixes 6360.
2015-08-20 23:04:18 +02:00
Jonas Jenwald
2597e3ffca Add a linked test-case for issue 4890 2015-08-18 22:33:09 +02:00
Jonas Jenwald
3fa5f6cc3b Only take the fast-path in PDFImage_createImageData for un-masked JPEG images with "standard" colour spaces (issue 6364)
Fixes 6364.
2015-08-18 22:25:37 +02:00
Jonas Jenwald
99d29487ab Adjust which TrueType (3, 1) glyphs we attempt to skip mapping of (issue 6336)
Fixes 6336.
2015-08-09 12:51:43 +02:00
Tim van der Meij
14f1ea00fe Test case for tensor shading PR 6310 2015-08-04 23:55:55 +02:00
Tilman Hausherr
c85fa00d62 fix handling of flags 1-3 in coons shading
Short story: somebody got lost in two different indices. pi is an index in the stream and is explained on page 198 of the 32000-spec (however 1-based there), and ps is an index to something in PDF.js. I used the code from flag 0 (which works) to understand which is which. It is also important to understand that for flags 1,2 and 3, the stream is always assigned to the same coordinates and colors. What changes is which "old" coordinates and colors are assigned to what is "missing" in the stream. This is why for these flags, the code is identical except for the assignments in the first "row".
2015-08-03 21:15:26 +02:00
Brendan Dahl
a32d521555 Merge pull request #6222 from Rob--W/botio-robustness
Improve robustness of builder (esp. on Windows)
2015-08-03 10:10:35 -07:00
Brendan Dahl
977397ebfd Merge pull request #6270 from Snuffleupagus/opentype-cff-2
Adjust the heuristics used to detect OpenType font file with CFF data (bug 1186827, bug 1182130, issue 6264)
2015-08-03 09:43:33 -07:00
Jonas Jenwald
1d65daf5e5 Correctly access colorSpace.numComps in MeshStreamReader (issue 6287)
This regressed in f750e35224.
2015-07-31 18:00:58 +02:00
Jonas Jenwald
7fe2442a18 Ensure that we don't use the same typed array for both coords and colors in Mesh figures (issue 6287)
This regressed in 1e8d70af98.
2015-07-31 18:00:23 +02:00
Tim van der Meij
d08895d659 Merge pull request #6236 from Rob--W/print-javascript-action
Detect scripted auto-print requests
2015-07-25 19:42:31 +02:00
Jonas Jenwald
0a024b5051 Adjust the heuristics used to detect OpenType font file with CFF data (bug 1186827, bug 1182130, issue 6264)
*This is a tentative patch.*

Fixes https://bugzilla.mozilla.org/show_bug.cgi?id=1186827.
Fixes https://bugzilla.mozilla.org/show_bug.cgi?id=1182130.
Fixes 6264.
2015-07-25 12:26:36 +02:00
Jonas Jenwald
385e2e5aaf Check if the Decode entry is non-default when deciding if JPEG images are natively supported/decodable (issue 6238)
Tentatively fixes 6238.
2015-07-21 12:23:07 +02:00
Tim van der Meij
980aa10e04 Refactor annotation rectangle code and add unit tests
This patch refactors the code responsible for setting the annotation's rectangle. Its goal is to:

- Actually check that the input array is actually an array, and if so, that it contains exactly four elements.
- Only call `normalizeRect` if the input array is valid, i.e., we do not call it for the default rectangle anymore.

Unit tests are provided just like with the other patches in this series.
2015-07-20 22:01:47 +02:00
Rob Wu
c676ecb5a0 Detect scripted auto-print requests
Fixes #6106

To avoid future regressions, two new unit tests were added:
1. A new PDF based on the report from #6106, which contains an
   OpenAction of type JavaScript and a string "this.print({...}".
2. An existing PDF from https://bugzil.la/1001080 (from #4698).

Although it does not matter, since we don't execute the JavaScript code,
I have also changed "print(true)" to "print({})" since the print method
takes an object (not a boolean). See "Printing PDF documents", page 62:
http://adobe.com/content/dam/Adobe/en/devnet/acrobat/pdfs/js_developer_guide.pdf
2015-07-20 18:25:02 +02:00
Tim van der Meij
dbd2ef034f Merge pull request #6196 from Rob--W/run-specific-test
Add --testfilter and -t flags
2015-07-19 13:55:07 +02:00
Rob Wu
b627a1a0d9 Add --testfilter (-t) flag to run a specific test 2015-07-18 17:31:56 +02:00
Rob Wu
cc0805a996 Reduce verbosity of output in test/webbrowser.js 2015-07-17 23:21:35 +02:00
Tim van der Meij
465611a2ff More cleanup regarding annotation border styles 2015-07-17 21:51:24 +02:00
Tim van der Meij
4b6e2724ae Merge pull request #6220 from Snuffleupagus/issue-6218
Ignore double negative in `Lexer_getNumber` (issue 6218)
2015-07-17 21:29:40 +02:00
Jonas Jenwald
d68eb153d3 Update fonttools location and version (issue 6223) 2015-07-17 12:51:09 +02:00
Rob Wu
c3c6d503ee Improve robustness of builder (esp. on Windows)
- Use rimraf instead of a custom removeDirSync implementation - rimraf
  deals with edge cases like EPERM on Windows.

- Detect when the process exits before it was requested via stop(),
  instead of running the cleanup handler.

- Add fallback for process detection when the process exits before it
  was requested. On *nix systems, this is done via pkill and pgrep, on
  Windows this is done via wmic.

- Add some asserts to check the preconditions of the methods, and output
  some status information to aid debugging in case of failure.

I have verified that these changes work on ArchLinux and Windows XP,
using Chrome and Firefox, as follows:

1. node make unittest

2. node make unittest
3. Restart the Firefox process via the task manager as soon as possible.

4. node make unittest
5. Temporary lock a file/directory within the temporary profile
   directory until the tests have finished, and then unlock the file
   within 10 seconds.

In all cases, the auxilary browser processes are killed, and the
temporary profile directory is wiped.
2015-07-16 21:40:57 +02:00
Jonas Jenwald
c718d1ab10 Ignore double negative in Lexer_getNumber (issue 6218)
Basic mathematics would suggest that a double negative should always become positive, but it appears that Adobe Reader simply ignores that case. Hence I think that it makes sense for us to do the same.

Fixes 6218.
2015-07-16 12:11:49 +02:00
Tim van der Meij
a2e9845093 Refactor annotation color handling and add unit tests 2015-07-15 18:49:19 +02:00
Rob Wu
62cf6536a2 Tests: Resolve -b to full path in webbrowser.js
This allows us to simply use "node test.js -b=firefox" instead of having
to type out the full path.
2015-07-14 00:20:07 +02:00
Tim van der Meij
1416a1b521 Merge pull request #6187 from Snuffleupagus/more-efficient-getDestination
A couple of improvements of `getDestination` (unit-test included)
2015-07-13 23:03:13 +02:00
Brendan Dahl
e498bbce90 Merge pull request #6198 from Rob--W/windows-taskkill
Use taskkill to stop the browser on Windows in tests
2015-07-13 13:30:03 -07:00
Rob Wu
5cce7377af Use taskkill to stop the browser on Windows 2015-07-11 20:22:53 +02:00
Rob Wu
e211c25f06 Improve robustness of stream parser (invalid length)
When the parser finds a stream, it retrieves the Length from the stream
dictionary and advances the lexer to the offset as specified in Length.
If this Length is incorrect, the lexer could end up anywhere.

When the lexer gets in an invalid state, it could throw errors. For
example, in issue 6108, the lexer ends up inside the stream data. This
stream has the ASCIIHexDecode filter, so all characters are made up from
ASCII characters, and the lexer interprets it as a command token. Tokens
cannot be longer than 127 bytes, so eventually 128 bytes are consumed
and the lexer throws "Command token too long" error.

Another possible error is "Illegal character: 41" when the lexer happens
to end up at a ')' due to the length mismatch.

These problems are solved by catching lexer errors and recovering the
parser via the existing stream length detection branch.
2015-07-11 20:12:49 +02:00
Rob Wu
fd29bb0c57 Subtract start offset for xrefs in recovery mode
Xref offsets are relative to the start of the PDF data, not to the start
of the PDF file. This is clear if you look at the other code:

- In the XRef's readXRefTable and processXRefTable methods of XRef, the
  offset of a xref entry is set to the bytes as given by a PDF file.
  These values are always relative to the start of the PDF file (%PDF-).

- The XRef's readXRef method adds the start offset of the stream to
  Xref entry's offset: "stream.pos = startXRef + stream.start".
  Clearly, this line assumes that the entry offset excludes the start
  offset.

However, when the PDF is parsed in recovery mode, the xref table is
filled with entries whose offset is relative to the start of the stream
rather than the PDF file. This is incorrect, and the fix is to subtract
the start offset of the stream from the entry's byte offset.

The manually created PDF file serves as a regression test. It is a valid
PDF, except:
- The integer to point to the start of the xref table and the %%EOF
  trailer are missing. This will activate recovery mode in PDF.js
- Some junk was added before the start of the PDF file. This exposes the
  bad offset bug.
2015-07-10 23:33:10 +02:00
Jonas Jenwald
940bedf75f Add a unit-test that attempts to fetch a non-existent named destination
Doing this helped uncover an issue with the `getDestination` implementation.
Currently if a named destination doesn't exist, the method (in `obj.js`) may return `undefined` which leads to the promise being stuck in a pending state.
*Note:* returning `null` for this case is consistent with other methods, e.g. `getOutline` and `getAttachments`.
2015-07-07 22:05:08 +02:00
Tim van der Meij
31976b9b44 Merge pull request #6181 from Rob--W/test-downloadOnly
Add --downloadOnly flag to test.js
2015-07-06 23:30:01 +02:00
Rob Wu
c7a5da332c Add --downloadOnly flag to test.js 2015-07-06 17:17:11 +02:00
Jonas Jenwald
60fc462bd6 Add more reduced test-cases for PR 6171 2015-07-03 13:14:41 +02:00
Yury Delendik
0787182e6f Adds more characters to the PUA range 2015-07-02 16:47:47 -05:00
Brendan Dahl
d8e201446d Merge pull request #6135 from Snuffleupagus/issue-5677-v2
Skip mapping of CIDFontType2 glyphs when the font either has a |IdentityToUnicodeMap| or a |toUnicodeMap| with 65536 elements (issue 5677)
2015-07-01 11:15:55 -07:00
Brendan Dahl
98339f63a8 Merge pull request #5585 from timvandermeij/annotation-layer-borderstyle
Annotation border styles
2015-07-01 10:48:12 -07:00
Tim van der Meij
e9a6d4451d Merge pull request #6146 from Snuffleupagus/issue-4909-test
Add a reduced test-case for issue 4909
2015-06-29 17:11:10 +02:00
Jonas Jenwald
38955d491f Further improvements of the getStats and getDownloadInfo unit tests
The patch adds a test to ensure that `getStats` returns the expected result after the page has been parsed, and cleans up the existing test a bit.
Also, since I'm touching the file anyway, I'm making a small adjustment of the `getDownloadInfo` test. (I have no idea why I didn't just write it like this initially.)
2015-06-25 23:00:26 +02:00
Jonas Jenwald
7b77408dc1 Add a reduced test-case for issue 4909
I *should* have included this is PR 4910, but for some reason I didn't so better late than never.
2015-06-25 22:34:44 +02:00
Jonas Jenwald
46a8485db4 Ignore paint form XObject when the name is missing (issue 4558)
Fixes 4558 (since the font issues already appear to be fixed).
2015-06-22 22:10:26 +02:00
Jonas Jenwald
aa3a64e975 Skip mapping of CIDFontType2 glyphs when the font either has a |IdentityToUnicodeMap| or a |toUnicodeMap| with 65536 elements (issue 5677)
This patch slightly extends the heuristics used when trying to skip mapping of missing glyphs.

Fixes 5677.
2015-06-18 21:53:15 +02:00
Tim van der Meij
6007a57291 Add tests and documentation for the annotation border style class
This patch adds:
- Unit tests for the annotation border style class
- Regression test (self-made) for the annotation border style class
- Documentation generation using JSDoc
2015-06-17 22:28:08 +02:00
Jonas Jenwald
75624c8d82 Clear the |getSinglePixelWidth| cache when rendering Type3 fonts (issue 6117)
Fixes 6117.
2015-06-17 14:30:32 +02:00
Jonas Jenwald
65fee79c5d Remove issue6113.pdf from the test-suite for failing intermittently in Firefox on the Linux bot 2015-06-16 19:40:24 +02:00
Jonas Jenwald
60fbb5ef69 Ensure that the result of |constructStichedFromIRResult| is a number (issue 6113)
Fixes 6113.
2015-06-14 23:29:38 +02:00
Jonas Jenwald
bc5e43b45c Use the Alternate entry, if it exists, in ICCBased Colour Space dictionaries (issue 5836, issue 5939, issue 6055)
Fixes 5836.
Fixes 5939.
Fixes 6055.
2015-06-14 12:10:22 +02:00
Jonas Jenwald
bf20334bea Merge pull request #6090 from Snuffleupagus/issue-6068
Map missing glyphs to the notdef glyph for TrueType (3, 1) fonts (issue 6068)
2015-06-13 00:29:08 +02:00
Tim van der Meij
fda6c18644 Merge pull request #6093 from Snuffleupagus/slightly-improved-crypto-unittests
Slightly improved Crypto unit tests
2015-06-10 00:32:35 +02:00
Jonas Jenwald
f59e20226c Slightly improved Crypto unit tests
Currently in the tests which check that incorrect passwords are rejected, we don't ensure that the exceptions thrown are the ones we expect. This patch improves the current situation, so that we actually can be sure that the code "fails" in the correct way.

*Note:* This patch also fixes some cases of weird indentation in the file.
2015-06-10 00:21:40 +02:00
Tim van der Meij
cbc7a0b178 Merge pull request #6101 from Snuffleupagus/issue-6099-test
Add a test-case for issue 6099 - CalRGB color space where the parameters are a |Ref|
2015-06-10 00:14:00 +02:00
Jonas Jenwald
97385587a8 Add a test-case for issue 6099 - CalRGB color space where the parameters are a |Ref|
The issue is already fixed by PR 5748, but we didn't have access to a suitable test-case. Thanks to issue 6099, we are now able to add one!
2015-06-09 17:52:36 +02:00
Jonas Jenwald
5eae3e29c5 Map missing glyphs to the notdef glyph for TrueType (3, 1) fonts (issue 6068)
Fixes 6068.

The most notable issue with the font in question is that the `differences` array contains lots of strange entries (of the type `uniXXXX`, instead of proper glyph names).
2015-06-06 18:28:16 +02:00
Jonas Jenwald
6f2f0700b7 Don't map glyphs to certain problematic Thai/Lao Unicode locations (issue 5994)
*This patch depends on PR 5990.*

According to https://dxr.mozilla.org/mozilla-central/source/gfx/harfbuzz/src/hb-ot-shape-fallback.cc#38, certain Thai/Lao characters are treated as special by the font shaping code in Firefox.
Further down in that file, https://dxr.mozilla.org/mozilla-central/source/gfx/harfbuzz/src/hb-ot-shape-fallback.cc#216, the vertical position of glyphs is modified, which should thus explain why some glyphs end up in the wrong position in the PDF file.

Fixes 5994.
2015-06-05 23:53:22 +02:00
Brendan Dahl
749a60a0b7 Merge pull request #5990 from Snuffleupagus/missing-glyphs-identityUnicode
Skip mapping of CIDFontType2 glyphs in fonts with a |IdentityToUnicodeMap|, unless |properties.widths| is defined for the glyph
2015-06-05 14:50:02 -07:00
Jonas Jenwald
64e1fb99fe Fetch parameters if they are |Ref|s in Pattern color spaces (issue 6081)
Fixes 6081.
2015-06-04 22:01:01 +02:00
Jonas Jenwald
a28ed7c834 Always traverse the entire parent chain in Page_getInheritedPageProp (issue 5954)
This enables us to find resources placed on multiple levels of the tree.

Fixes 5954.
2015-05-30 12:21:05 +02:00
Yury Delendik
d105734686 Merge pull request #6046 from AppShuttle/pdf-version-fix
Extract correct PDF format version from the catalog
2015-05-27 08:50:20 -05:00
Jonas Jenwald
39d2103063 Merge pull request #6021 from timvandermeij/test-driver
Refactor the test driver
2015-05-26 21:01:13 +02:00
Mike Corbin
4c9b65f0e1 Extract correct PDF format version from the catalog
The 'Version' field of the most recent document catalog, if present, is
intended to supersede the value in the file prologue.

This is significant for incrementally-built PDF documents and generators that
emit a low version in the prologue and later apply a format version based on
PDF features used, such as Apple's CoreGraphics/Quartz PDF backend.

Fixes the internal version variable, as well as the PDFFormatVersion reported
by the API and consumed by viewers.
2015-05-26 01:56:09 +01:00
Tim van der Meij
e02ab9fb79 Implement an option to disable automatic scrolling
This adds a checkbox with which one can disable scrolling, for example to look back at output during testing. Note that the styles are inline because the test runner removes all <style> elements for each test.
2015-05-21 20:19:36 +02:00
Tim van der Meij
07ec736eb9 Improve driver code structure
- Improve variable names and move variables to the top of the method
- Use constants where possible
- Only print the delay text if there is an atual delay set
- Simplify continuation logic in _nextTask
- Do not pass anything to clearCanvas: we can get the context from this.canvas there.
- Remove innerHTML and replace it with textContent. Add a comment why insertAdjancentHTML is so important for performance and runtime.
- Merge _quit and _sendQuitRequest.
2015-05-21 20:19:32 +02:00
Tim van der Meij
ae8748edfb Refactor test driver to be more class-like
- Extract NullTextLayerBuilder and SimpleTextLayerBuilder from the driver code and create classes for them.
- Move options to the constructor and pass in HTML elements instead of getting them in the driver.
- Remove unused masterMode variable.
- Minor method name updates.

The rest is only moving/indenting existing code and adding 'this'.
2015-05-21 20:19:02 +02:00
Yury Delendik
07af86cf70 Merge pull request #6016 from Snuffleupagus/issue-6010
Convert UTF8 encoded passwords to ISO-8859-1 for |R = 6| encryption (issue 6010)
2015-05-18 08:22:47 -05:00
Tim van der Meij
d59660cfa6 Clean up the test driver
- Remove a hack for Chrome on Windows because we do not run Chrome on the Windows bot anymore, so it added unneeded complexity.
- Merge nextTask and continueNextTask functions. nextTask did nothing more than calling cleanup. This change also allows us to remove the callback for that function.
- Remove unnecessary one-line functions.
2015-05-15 23:21:20 +02:00
Tim van der Meij
58769fd3b9 Refactor test slave
- Improved names of elements
- Easier scrolling code
2015-05-15 23:20:14 +02:00
Tim van der Meij
7da9626d16 Merge pull request #5901 from Snuffleupagus/bug-1050040
Fall back to the |defaultEncoding| when no valid "post" table is found in TrueType fonts (bug 1050040)
2015-05-15 12:54:04 +02:00
Jonas Jenwald
6fbc5428bd Skip mapping of CIDFontType2 glyphs in fonts with a |IdentityToUnicodeMap|, unless |properties.widths| is defined for the glyph
Fixes https://bugzilla.mozilla.org/show_bug.cgi?id=1142033.
Also fixes issue 5874.
2015-05-14 22:38:04 +02:00
Jonas Jenwald
44240798be Convert UTF8 encoded passwords to ISO-8859-1 for |R = 6| encryption (issue 6010)
For passwords where the encoding already is correct, the conversion is a no-op.
Also, since `encodeURIComponent` might throw, we need to make sure that we handle that case too.

Fixes 6010.
2015-05-14 21:46:31 +02:00
Tim van der Meij
90982332bf Merge pull request #5995 from CodingFabian/tweak-char-spacing-text-selection
Apply char spacing only when there are chars.
2015-05-14 20:06:22 +02:00
Jonas Jenwald
9788ba0270 Add a reduced test-case for issue 5896
This should have been part of PR 5898.
2015-05-14 14:08:43 +02:00
Jonas Jenwald
0365baf5ab Fall back to the |defaultEncoding| when no valid "post" table is found in TrueType fonts (bug 1050040)
Fixes https://bugzilla.mozilla.org/show_bug.cgi?id=1050040.

With this patch the file is completely readable, but given that the font is broken enough to be rejected by OTS the rendering differs slightly from Adobe Reader.

*Note:* the PDF file is sufficiently broken that even Adobe Reader complains about the font, *and* also about another more general issue.
2015-05-14 13:16:14 +02:00
Fabian Lange
c2013094e7 Apply char spacing only when there are chars. 2015-05-13 23:45:20 +02:00
Tim van der Meij
d484ebd492 Merge pull request #5910 from jordan-thoms/fix-concatenated-files
Fix error reading concatenated pdfs
2015-05-13 22:40:55 +02:00
Jonas Jenwald
6d2d854f65 Merge pull request #5815 from Snuffleupagus/type1-diff-refs
Ensure that entries in the Differences array of Type1 fonts are either numbers or names
2015-05-07 22:33:23 +02:00
Brendan Dahl
cd53cbe7d4 Merge pull request #5964 from Snuffleupagus/bug-1157493
Handle the Encoding being a dictionary in PartialEvaluator_preEvaluateFont (bug 1157493)
2015-05-05 14:41:32 -07:00
Brendan Dahl
4824baf31c Merge pull request #5905 from timvandermeij/specialpowers
Remove SpecialPowers addon
2015-04-27 10:36:54 -07:00
Jonas Jenwald
760222cf0b Handle the Encoding being a dictionary in PartialEvaluator_preEvaluateFont (bug 1157493)
*This is a regression from PR 4423.*

Fixes https://bugzilla.mozilla.org/show_bug.cgi?id=1157493.
2015-04-25 16:48:14 +02:00
Jonas Jenwald
4a022bc40a Add a reduced test-case for issue 5801 2015-04-25 11:28:33 +02:00
Jonas Jenwald
7c7d05e7a3 Attempt to infer if a CMap file actually contains just a standard Identity-H/Identity-V map 2015-04-25 11:28:33 +02:00
Tim van der Meij
48b2f6d023 Merge pull request #5756 from Snuffleupagus/issue-5751
Guess CIDFontType0 subtype based on font file contents (issue 5751)
2015-04-24 23:50:07 +02:00
Brendan Dahl
846eb967cc Merge pull request #5655 from Snuffleupagus/issue-5644
Avoid getting stuck in empty nodes in the Pages tree when calling |Catalog_getPageDict| (issue 5644)
2015-04-20 11:46:27 -07:00
Jordan Thoms
d0ea772fc6 Fix error reading concatenated pdfs 2015-04-18 20:56:07 +12:00
Jonas Jenwald
4c2ad3bc7b Ensure that entries in the Differences array of Type1 fonts are either numbers or names
This patch is yet another installment in the (never ending) series of bugs in PDF files with non-embedded fonts.

Fixes http://www.int.washington.edu/talks/WorkShops/int_08_37W/People/Franz_M/Franz.pdf.
2015-04-17 20:32:27 +02:00
Marco Castelluccio
fbae39983c Fail with a more informative error message if the browser executable path doesn't exist 2015-04-17 16:12:13 +02:00
Jonas Jenwald
fda858ae33 Don't map glyphs to certain problematic General Punctuation Unicode locations (bug 911034)
Fixes the remaining missing characters in https://bugzilla.mozilla.org/show_bug.cgi?id=911034.

For reference, see http://www.unicode.org/charts/PDF/U2000.pdf (and also http://en.wikipedia.org/wiki/General_Punctuation_%28Unicode_block%29).
2015-04-09 17:27:03 +02:00
Tim van der Meij
ba8a4f2b3e Merge pull request #5911 from Snuffleupagus/test-worker-comments
Remove commented out code about |disableWorker| in the test suite
2015-04-04 14:46:13 +02:00
Jonas Jenwald
36ac67583f Remove commented out code about |disableWorker| in the test suite
Since the tests have run with workers enabled for a long time, these comments are no longer relevant.
2015-04-04 13:32:44 +02:00
Tim van der Meij
50573b82a3 Provide only one browser manifest example 2015-04-03 21:21:54 +02:00
Tim van der Meij
27170ff858 Remove prefs.js file
The first preference is also in user.js and the second one was only needed for SpecialPowers.
2015-04-03 20:18:42 +02:00
Tim van der Meij
75d8f70d06 Remove SpecialPowers addon 2015-04-03 20:17:20 +02:00
Jonas Jenwald
2b1a13ba28 Don't map glyphs to Unicode position 0x0E33, i.e. Thai character SARA AM (bug1046314)
*A similar approach as in PR 5705.*

Fixes https://bugzilla.mozilla.org/show_bug.cgi?id=1046314.

According to https://dxr.mozilla.org/mozilla-central/source/gfx/harfbuzz/src/hb-ot-shape-complex-thai.cc#270-365, `0x0E33` is treated as a special case (by the font shaping code in Firefox). Hence it seems reasonable to skip it when adjusting the font mapping.
2015-03-26 13:22:45 +01:00
Brendan Dahl
519b6669f0 Merge pull request #5705 from Snuffleupagus/bug-1108301
Don't map glyphs to Unicode "Dotted circle" combining mark (bug 1108301)
2015-03-24 16:33:04 -07:00
Jonas Jenwald
e894a0a4c6 Guess CIDFontType0 subtype based on font file contents (issue 5751) 2015-03-15 13:35:48 +01:00
Jonas Jenwald
4a9ff471c4 Correctly detect the presence of the Adobe specific APP14 JPEG marker (bug 1140761)
According to the specification, http://partners.adobe.com/public/developer/en/ps/sdk/5116.DCT_Filter.pdf#G3.851943, the content of the marker segment should begin with `Adobe`, and not `Adobe\x00` as the code currently look for.

Fixes https://bugzilla.mozilla.org/show_bug.cgi?id=1140761.
Fixes the colour conversion part of issues 4090 and 5623.
2015-03-10 13:07:09 +01:00
Yury Delendik
f4dbd69e06 Merge pull request #5595 from fkaelberer/useBinarySearchToFindVisibleElements
Use binary search in getVisibleElements()
2015-03-09 23:11:50 -05:00
Tim van der Meij
c69ad5885c Merge pull request #5770 from Snuffleupagus/opentype-cff
Correctly detect OpenType font files with CFF data
2015-03-06 22:58:43 +01:00
Jonas Jenwald
97eb215b5f Add a reduced test-case for issue 5734 2015-03-05 16:20:03 +01:00
Jonas Jenwald
82f73bc9f4 Add a |text| test-case for issue 5421
Prior to PR 4259, we *incorrectly* ignored `toUnicode` for Type3 fonts. Since we now handle that correctly, this patch adds a `text` test-case to prevent regressions.
2015-03-03 13:13:34 +01:00
fkaelberer
a78bb6b946 Use binary search in getVisibleElements() 2015-03-01 17:41:20 +01:00
Jonas Jenwald
f81fc9091a Correctly detect OpenType font files with CFF data
Fixes 5334.
Fixes 215.
Fixes https://bugzilla.mozilla.org/show_bug.cgi?id=1125614.

According to the specification, http://www.microsoft.com/typography/otspec/otff.htm, OpenType font files with CFF data should have `OTTO` in the header.
2015-02-28 13:43:53 +01:00
Jonas Jenwald
00ee6bd6b6 Merge pull request #5693 from collinanderson/whitespace
cleaned whitespace
2015-02-28 10:09:21 +01:00
Yury Delendik
23916b2b14 Merge pull request #5748 from Snuffleupagus/issue-5747
Fetch parameters if they are a |Ref| in CalGray/CalRGB color spaces (issue 5747)
2015-02-26 17:44:46 -06:00
Jonas Jenwald
0a3341dadc Don't map glyphs to Unicode "Dotted circle" combining mark (bug 1108301)
It seems that `0x25CC` is another bad spot for charCodes.
Fixes https://bugzilla.mozilla.org/show_bug.cgi?id=1108301.
2015-02-27 00:20:38 +01:00
Jonas Jenwald
888cbe0bde Avoid getting stuck in empty nodes in the Pages tree when calling |Catalog_getPageDict| (issue 5644) 2015-02-22 17:42:15 +01:00
Jonas Jenwald
7c8996558a Fetch parameters if they are a |Ref| in CalGray/CalRGB color spaces (issue 5747) 2015-02-20 12:53:02 +01:00
Jonas Jenwald
417800a1b5 Only skip the |!isSymbolicFont| check for TrueType (3, 1) cmap tables if no previous cmap table was found (PR 5703 followup)
Fixes https://bugzilla.mozilla.org/show_bug.cgi?id=894572.
2015-02-19 13:58:03 +01:00
Brendan Dahl
6bb0a483b1 Merge pull request #5703 from Snuffleupagus/issue-5701
Relax the |isSymbolicFont| check for TrueType (3, 1) cmap tables (issue 5701)
2015-02-18 14:50:19 -08:00
Collin Anderson
54e984c763 cleaned whitespace 2015-02-17 11:07:37 -05:00
Tim van der Meij
27e3558a41 Fix CCITTStream regression by byte-aligning rows before checking EOL marker 2015-02-13 21:29:00 +01:00
Jonas Jenwald
592890a758 Relax the |isSymbolicFont| check for TrueType (3, 1) cmap tables (issue 5701) 2015-02-13 01:03:10 +01:00
Jonas Jenwald
8614c17c1d Merge pull request #5717 from timvandermeij/testcase-5567
Test case for issue 5567
2015-02-13 00:39:52 +01:00
Brendan Dahl
394b38b22f Merge pull request #5651 from Snuffleupagus/missing-glyphs
Try to skip mapping of missing TrueType and CIDFontType2 glyphs
2015-02-11 19:31:22 -08:00
Tim van der Meij
d124fc5e08 Test case for issue 5567 2015-02-10 00:16:54 +01:00
Jonas Jenwald
01e6565dd4 Try to skip mapping of missing TrueType glyphs
Also don't skip mapping of glyphs which are empty, if the corresponding charCode is included in toUnicode.
2015-02-07 12:19:38 +01:00
Jonas Jenwald
8174da61fb Don't skip mapping of glyphs for CIDFontType2 fonts with a CIDToGIDMap
Also don't skip mapping of glyphs which are empty, if the corresponding charCode is included in toUnicode.
2015-02-07 12:19:37 +01:00
Jonas Jenwald
ad41a2d574 Add support for TrueType (0, 0) cmap tables (issue 5501 and 5574) 2015-01-11 14:54:12 +01:00
Jonas Jenwald
5332c02a02 Fix lint error: "test/webserver.js: line 177, col 106, Line is too long." 2015-01-08 12:22:34 +01:00
Yury Delendik
4ec132a2ba Adds encoding for test server index page. 2015-01-07 21:35:48 -06:00
Jonas Jenwald
1fea44ce14 Ensure that |get fingerprint| doesn't fail if the ID is not an array (issue 5599)
According to the [PDF specification](http://www.adobe.com/content/dam/Adobe/en/devnet/acrobat/pdfs/PDF32000_2008.pdf#page=51) the `ID` should be an array. To prevent errors if the PDF file violates that part of the spec, check that the `ID` is actually an array.

Fixes 5599.
2014-12-30 16:16:43 +01:00
Jonas Jenwald
6e66e30d92 Merge pull request #5597 from timvandermeij/ccitt-regression
CCITTFaxStream: fix regression when EncodedByteAlign is true and EndOfLine is false
2014-12-30 11:48:47 +01:00
Tim van der Meij
b835ef425e CCITTFaxStream: fix regression when EncodedByteAlign is true and EndOfLine is false 2014-12-30 00:07:35 +01:00
Jonas Jenwald
75767abb09 Add a reduced test case for issue 4379
This should have been part of PR 5136.

Based on comments https://github.com/mozilla/pdf.js/issues/4379#issuecomment-51221787 and https://github.com/mozilla/pdf.js/issues/4379#issuecomment-51475463, it should be OK to include the PDF file in the repo.
2014-12-29 16:28:23 +01:00
Jonas Jenwald
d8b905048b Add fallback for non-embedded "Century Gothic" CIDFontType2 font (issue 4722 and bug 879561)
According to practical experiments, falling back to "Helvetica" when we encounter a non-embedded "[Century Gothic](http://en.wikipedia.org/wiki/Century_Gothic)" `CIDFontType2` font seems to work well.
(Also, the section on Wikipedia about "Printer ink usage" *might* provide some anecdotal evidence that Century Gothic is a fairly standard sans-serif font.)

Obviously this patch doesn't make "Century Gothic" fonts render perfectly, as is often the case with non-embedded fonts, but all the text is now legible in the referenced issues.

Fixes 4722.
Fixes https://bugzilla.mozilla.org/show_bug.cgi?id=879561.
2014-12-18 23:19:34 +01:00
Tim van der Meij
a340927687 Test case for issue 5481 2014-12-18 21:26:02 +01:00
Yury Delendik
31ae5f2a3d Merge pull request #5379 from brendandahl/nbsp
Don't map glyphs to unicode non breaking space.
2014-12-18 13:38:03 -06:00
Yury Delendik
f4fa7aaf19 Merge pull request #5383 from Snuffleupagus/bug-1077808
Fix searching for end of inline (EI) images with ASCII85Decode filters (bug 1077808)
2014-12-18 10:03:27 -06:00
Tim van der Meij
36fce7db7e Test case for issue 5475 2014-12-17 22:46:47 +01:00
Tim van der Meij
16833159a9 Test case for issue 5549 2014-12-17 22:42:06 +01:00
Jonas Jenwald
184880a751 Fix searching for end of inline (EI) images with ASCII85Decode filters (bug 1077808)
This patch changes searching for the end of inline image streams to rely on the EOD marker for the filters: ASCII85Decode and ASCIIHexDecode.
2014-12-15 18:48:29 +01:00
Jonas Jenwald
3ea81019fe Add a (linked) test case for bug 1108753 (PR 5276)
When submitting PR 5276 there wasn't a good PDF file to include in the test suite. However, with https://bugzilla.mozilla.org/show_bug.cgi?id=1108753, we now have a better source for a test file, hence this patch.
2014-12-09 01:07:38 +01:00
Jonas Jenwald
df1364a993 Add a (linked) test case for bug 1064894
This should have been part of PR 5284.
2014-12-06 14:15:08 +01:00
Jonas Jenwald
78d0d269dc Fallback to the |Dummy| Pattern when we fail to parse a Shading Pattern (issue 5509) 2014-11-30 21:21:45 +01:00
Jonas Jenwald
5f32f80e34 Add a reduced test case for issue 5470 2014-11-04 16:16:48 +01:00
Yury Delendik
a737e5b706 Merge pull request #5437 from Snuffleupagus/bug-878194-eq-test
Change bug878194 to an |eq| test
2014-10-27 08:32:03 -07:00
Jonas Jenwald
58cc39f329 Add a reduced test case for issue 5291 2014-10-25 11:35:13 +02:00
Jonas Jenwald
bf0d03bccd Change bug878194 to an |eq| test 2014-10-23 14:19:05 +02:00
Yury Delendik
04390d8252 Merge pull request #5426 from fkaelberer/fixJpxOutOfPackets
Fix JPX "Out of Packets" Error (issues 4358, 4659, 4814)
2014-10-22 09:40:29 -05:00
Yury Delendik
9e7966a446 Merge pull request #5390 from Snuffleupagus/inline-jpeg-image-loading-test-case
Add a reduced test case for PR 5286
2014-10-22 09:38:31 -05:00
Yury Delendik
6b2c900722 Merge pull request #5401 from Snuffleupagus/bug-847420-test
Add a reduced test case for bug 847420
2014-10-22 08:32:20 -05:00
Jonas Jenwald
88c88d08e1 Add a reduced test case for PR 5286 2014-10-22 14:11:15 +02:00