diff --git a/extensions/firefox/components/PdfStreamConverter.js b/extensions/firefox/components/PdfStreamConverter.js
index a0057ebb6..d371e50cd 100644
--- a/extensions/firefox/components/PdfStreamConverter.js
+++ b/extensions/firefox/components/PdfStreamConverter.js
@@ -132,16 +132,13 @@ ChromeActions.prototype = {
var originalUrl = data.originalUrl;
// The data may not be downloaded so we need just retry getting the pdf with
// the original url.
- var blobUrl = data.blobUrl || originalUrl;
- var originalUri = NetUtil.newURI(originalUrl);
- var blobUri = NetUtil.newURI(blobUrl);
+ var originalUri = NetUtil.newURI(data.originalUrl);
+ var blobUri = data.blobUrl ? NetUtil.newURI(data.blobUrl) : originalUri;
var extHelperAppSvc =
Cc['@mozilla.org/uriloader/external-helper-app-service;1'].
getService(Ci.nsIExternalHelperAppService);
var frontWindow = Cc['@mozilla.org/embedcomp/window-watcher;1'].
getService(Ci.nsIWindowWatcher).activeWindow;
- var ioService = Services.io;
- var channel = ioService.newChannel(originalUrl, null, null);
NetUtil.asyncFetch(blobUri, function(aInputStream, aResult) {
if (!Components.isSuccessCode(aResult)) {
diff --git a/l10n/en-US/chrome.properties b/l10n/en-US/chrome.properties
index 1885e6036..2b3dce42f 100644
--- a/l10n/en-US/chrome.properties
+++ b/l10n/en-US/chrome.properties
@@ -1,3 +1,4 @@
# Chrome notification bar messages and buttons
unsupported_feature=This PDF document might not be displayed correctly.
open_with_different_viewer=Open With Different Viewer
+open_with_different_viewer.accessKey=o
diff --git a/l10n/en-US/viewer.properties b/l10n/en-US/viewer.properties
index de6fd95db..1c4dd1cde 100644
--- a/l10n/en-US/viewer.properties
+++ b/l10n/en-US/viewer.properties
@@ -87,3 +87,5 @@ loading_error=An error occurred while loading the PDF.
# Some common types are e.g.: "Check", "Text", "Comment", "Note"
text_annotation_type=[{{type}} Annotation]
request_password=PDF is protected by a password:
+
+printing_not_supported=Warning: Printing is not fully supported by this browser.
diff --git a/src/canvas.js b/src/canvas.js
index cc6d50ded..32c171216 100644
--- a/src/canvas.js
+++ b/src/canvas.js
@@ -1196,20 +1196,20 @@ var CanvasGraphics = (function CanvasGraphicsClosure() {
// Marked content
markPoint: function CanvasGraphics_markPoint(tag) {
- TODO('Marked content');
+ // TODO Marked content.
},
markPointProps: function CanvasGraphics_markPointProps(tag, properties) {
- TODO('Marked content');
+ // TODO Marked content.
},
beginMarkedContent: function CanvasGraphics_beginMarkedContent(tag) {
- TODO('Marked content');
+ // TODO Marked content.
},
beginMarkedContentProps: function CanvasGraphics_beginMarkedContentProps(
tag, properties) {
- TODO('Marked content');
+ // TODO Marked content.
},
endMarkedContent: function CanvasGraphics_endMarkedContent() {
- TODO('Marked content');
+ // TODO Marked content.
},
// Compatibility
diff --git a/src/core.js b/src/core.js
index 8e07078ef..409ae060d 100644
--- a/src/core.js
+++ b/src/core.js
@@ -399,9 +399,14 @@ var PDFDocument = (function PDFDocumentClosure() {
var length = this.stream.length;
var linearization = false;
if (length) {
- linearization = new Linearization(this.stream);
- if (linearization.length != length)
- linearization = false;
+ try {
+ linearization = new Linearization(this.stream);
+ if (linearization.length != length)
+ linearization = false;
+ } catch (err) {
+ warn('The linearization data is not available ' +
+ 'or unreadable pdf data is found');
+ }
}
// shadow the prototype getter with a data property
return shadow(this, 'linearization', linearization);
diff --git a/src/fonts.js b/src/fonts.js
index ba94f4305..6589901bd 100644
--- a/src/fonts.js
+++ b/src/fonts.js
@@ -3422,6 +3422,40 @@ var Type1Parser = function type1Parser() {
var kEscapeCommand = 12;
+ // Breaks up the stack by arguments and also calculates the value.
+ function breakUpArgs(stack, numArgs) {
+ var args = [];
+ var index = stack.length - 1;
+ for (var i = 0; i < numArgs; i++) {
+ if (index < 0) {
+ args.unshift({ arg: [0],
+ value: 0 });
+ warn('Malformed charstring stack: not enough values on stack.');
+ continue;
+ }
+ var token = stack[index];
+ if (token === 'div') {
+ var a = stack[index - 2];
+ var b = stack[index - 1];
+ if (!isInt(a) || !isInt(b)) {
+ warn('Malformed charsting stack: expected ints on stack for div.');
+ a = 0;
+ b = 1;
+ }
+ args.unshift({ arg: [a, b, 'div'],
+ value: a / b });
+ index -= 3;
+ } else if (isInt(token)) {
+ args.unshift({ arg: stack.slice(index, index + 1),
+ value: token });
+ index--;
+ } else {
+ warn('Malformed charsting stack: found bad token ' + token + '.');
+ }
+ }
+ return args;
+ }
+
function decodeCharString(array) {
var charstring = [];
var lsb = 0;
@@ -3475,25 +3509,17 @@ var Type1Parser = function type1Parser() {
command = charStringDictionary['12'][escape];
} else {
- // TODO Clean this code
if (value == 13) { // hsbw
- if (charstring.length == 2) {
- lsb = charstring[0];
- width = charstring[1];
- charstring.splice(0, 1);
- } else if (charstring.length == 4 && charstring[3] == 'div') {
- lsb = charstring[0];
- width = charstring[1] / charstring[2];
- charstring.splice(0, 1);
- } else if (charstring.length == 4 && charstring[2] == 'div') {
- lsb = charstring[0] / charstring[1];
- width = charstring[3];
- charstring.splice(0, 3);
- } else {
- error('Unsupported hsbw format: ' + charstring);
- }
-
- charstring.push(lsb, 'hmoveto');
+ var args = breakUpArgs(charstring, 2);
+ var arg0 = args[0];
+ var arg1 = args[1];
+ lsb = arg0.value;
+ width = arg1.value;
+ // To convert to type2 we have to move the width value to the first
+ // part of the charstring and then use hmoveto with lsb.
+ charstring = arg1.arg;
+ charstring = charstring.concat(arg0.arg);
+ charstring.push('hmoveto');
continue;
} else if (value == 10) { // callsubr
if (charstring[charstring.length - 1] < 3) { // subr #0..2
diff --git a/src/stream.js b/src/stream.js
index 5e4b3a47e..bd239dacc 100644
--- a/src/stream.js
+++ b/src/stream.js
@@ -852,7 +852,7 @@ var JpegStream = (function JpegStreamClosure() {
*/
JpegStream.prototype.isNativelySupported =
function JpegStream_isNativelySupported(xref, res) {
- var cs = ColorSpace.parse(this.dict.get('ColorSpace'), xref, res);
+ var cs = ColorSpace.parse(this.dict.get('ColorSpace', 'CS'), xref, res);
// when bug 674619 lands, let's check if browser can do
// normal cmyk and then we won't need to decode in JS
if (cs.name === 'DeviceGray' || cs.name === 'DeviceRGB')
@@ -867,7 +867,7 @@ var JpegStream = (function JpegStreamClosure() {
*/
JpegStream.prototype.isNativelyDecodable =
function JpegStream_isNativelyDecodable(xref, res) {
- var cs = ColorSpace.parse(this.dict.get('ColorSpace'), xref, res);
+ var cs = ColorSpace.parse(this.dict.get('ColorSpace', 'CS'), xref, res);
var numComps = cs.numComps;
if (numComps == 1 || numComps == 3)
return true;
diff --git a/test/mozcentral/Makefile.in b/test/mozcentral/Makefile.in
index 93ec187e2..ca686d1b4 100644
--- a/test/mozcentral/Makefile.in
+++ b/test/mozcentral/Makefile.in
@@ -9,13 +9,11 @@ VPATH = @srcdir@
relativesrcdir = browser/extensions/pdfjs/test
include $(DEPTH)/config/autoconf.mk
-include $(topsrcdir)/config/rules.mk
-_BROWSER_TEST_FILES = \
+MOCHITEST_BROWSER_FILES = \
browser_pdfjs_main.js \
browser_pdfjs_savedialog.js \
file_pdfjs_test.pdf \
$(NULL)
-libs:: $(_BROWSER_TEST_FILES)
- $(INSTALL) $(foreach f,$^,"$f") $(DEPTH)/_tests/testing/mochitest/browser/$(relativesrcdir)
+include $(topsrcdir)/config/rules.mk
diff --git a/test/pdfs/issue1419.pdf.link b/test/pdfs/issue1419.pdf.link
new file mode 100644
index 000000000..7fe9f28bc
--- /dev/null
+++ b/test/pdfs/issue1419.pdf.link
@@ -0,0 +1 @@
+http://www.meal-a-day.asia/sites/default/files/Meal-a-Day%20Asia-Pacific%20Biennial%20Report%202012%20v1.01.pdf
diff --git a/test/test_manifest.json b/test/test_manifest.json
index e515bbe69..1b372e906 100644
--- a/test/test_manifest.json
+++ b/test/test_manifest.json
@@ -604,6 +604,15 @@
"link": true,
"type": "eq"
},
+ { "id": "issue1419.pdf",
+ "file": "pdfs/issue1419.pdf",
+ "md5": "b5b6c6405d7b48418bccf97277957664",
+ "rounds": 1,
+ "link": true,
+ "pageLimit": 1,
+ "skipPages": [1],
+ "type": "eq"
+ },
{ "id": "issue1317",
"file": "pdfs/issue1317.pdf",
"md5": "6fb46275b30c48c8985617d4f86199e3",
diff --git a/web/viewer.css b/web/viewer.css
index b8e86f2c8..80a8c5a40 100644
--- a/web/viewer.css
+++ b/web/viewer.css
@@ -1113,7 +1113,16 @@ canvas {
font-size: 10px;
}
+@page {
+ margin: 0;
+}
+
+#printContainer {
+ display: none;
+}
+
@media print {
+ /* Rules for browsers that don't support mozPrintCallback. */
#sidebarContainer, .toolbar, #loadingBox, #errorWrapper, .textLayer {
display: none;
}
@@ -1135,6 +1144,19 @@ canvas {
.page[data-loaded] {
display: block;
}
+
+ /* Rules for browsers that support mozPrintCallback */
+ body[data-mozPrintCallback] #outerContainer {
+ display: none;
+ }
+ body[data-mozPrintCallback] #printContainer {
+ display: block;
+ }
+ #printContainer canvas {
+ position: relative;
+ top: 0;
+ left: 0;
+ }
}
@media all and (max-width: 950px) {
diff --git a/web/viewer.html b/web/viewer.html
index c59d9fcf3..28e57f700 100644
--- a/web/viewer.html
+++ b/web/viewer.html
@@ -102,11 +102,9 @@
Open
-