mirror of
https://github.com/mozilla/pdf.js.git
synced 2025-04-20 23:28:06 +02:00
Merge branch 'master' of github.com:mozilla/pdf.js into seac
This commit is contained in:
commit
6ed639e4d8
13 changed files with 189 additions and 42 deletions
|
@ -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
|
||||
|
|
11
src/core.js
11
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);
|
||||
|
|
62
src/fonts.js
62
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
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue