Working towards embedded image support

This commit is contained in:
Julian Viereck 2011-09-05 18:41:11 -07:00
parent cc17707da6
commit eca8f6b80b
2 changed files with 47 additions and 4 deletions

37
pdf.js
View File

@ -4251,12 +4251,33 @@ var PartialEvaluator = (function() {
);
if ('Form' == type.name) {
args[0].code = this.evaluate(xobj, xref,
xobj.dict.get('Resources'), fonts,
images);
// console.log("got xobj that is a Form");
args[0].code = this.eval(xobj, xref, xobj.dict.get('Resources'),
fonts, images);
}
if (xobj instanceof JpegStream)
if (xobj instanceof JpegStream) {
images.bind(xobj); // monitoring image load
// console.log("got xobj that is a JpegStream");
}
if (xobj.dict.get('Subtype').name == "Image") {
// Check if we have an image that is not rendered by the platform.
// Needs to be rendered ourself.
if (!(xobj instanceof JpegStream)) {
var image = xobj;
var dict = image.dict;
var w = dict.get('Width', 'W');
var h = dict.get('Height', 'H');
var inline = false;
var imageObj = new PDFImage(xref, resources, image, inline);
console.log("xobj subtype image", w, h, imageObj.imageMask);
}
}
console.log("xobj subtype", xobj.dict.get('Subtype').name);
}
} else if (cmd == 'Tf') { // eagerly collect all fonts
var fontName = args[0].name;
@ -4285,6 +4306,14 @@ var PartialEvaluator = (function() {
}
}
var skips = ["paintXObject"];
if (skips.indexOf(fn) != -1) {
// console.log("skipping", fn);
args = [];
continue;
}
fnArray.push(fn);
argsArray.push(args);
args = [];

View File

@ -50,6 +50,20 @@ var handler = new MessageHandler("worker", {
// TODO: Handle images here.
console.log("about to send page", pageNum);
// Make a copy of the fnArray and show all cmds it has.
var fnArray = preCompilation.fnArray.slice(0).sort();
for (var i = 0; i < fnArray.length; true) {
if (fnArray[i] == fnArray[i + 1]) {
fnArray.splice(i, 1);
} else {
i++;
}
}
console.log("cmds", fnArray);
handler.send("page", {
pageNum: pageNum,
fonts: fontsMin,