mirror of
https://github.com/mozilla/pdf.js.git
synced 2025-04-26 01:58:06 +02:00
Separate page objects/images from the fonts; does not store large images
This commit is contained in:
parent
d2c1868497
commit
69b72078c0
7 changed files with 97 additions and 73 deletions
|
@ -18,12 +18,13 @@
|
|||
'use strict';
|
||||
|
||||
var PartialEvaluator = (function PartialEvaluatorClosure() {
|
||||
function PartialEvaluator(xref, handler, uniquePrefix) {
|
||||
function PartialEvaluator(xref, handler, pageIndex, uniquePrefix) {
|
||||
this.state = new EvalState();
|
||||
this.stateStack = [];
|
||||
|
||||
this.xref = xref;
|
||||
this.handler = handler;
|
||||
this.pageIndex = pageIndex;
|
||||
this.uniquePrefix = uniquePrefix;
|
||||
this.objIdCounter = 0;
|
||||
this.fontIdCounter = 0;
|
||||
|
@ -151,7 +152,7 @@ var PartialEvaluator = (function PartialEvaluatorClosure() {
|
|||
if (!isDict(font)) {
|
||||
return {
|
||||
translated: new ErrorFont('Font ' + fontName + ' is not available'),
|
||||
loadedName: 'font_' + this.uniquePrefix + this.fontIdCounter
|
||||
loadedName: 'g_font_' + this.uniquePrefix + this.fontIdCounter
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -159,7 +160,7 @@ var PartialEvaluator = (function PartialEvaluatorClosure() {
|
|||
if (!loadedName) {
|
||||
// keep track of each font we translated so the caller can
|
||||
// load them asynchronously before calling display on a page
|
||||
loadedName = 'font_' + this.uniquePrefix + this.fontIdCounter;
|
||||
loadedName = 'g_font_' + this.uniquePrefix + this.fontIdCounter;
|
||||
font.loadedName = loadedName;
|
||||
|
||||
var translated;
|
||||
|
@ -197,6 +198,7 @@ var PartialEvaluator = (function PartialEvaluatorClosure() {
|
|||
var self = this;
|
||||
var xref = this.xref;
|
||||
var handler = this.handler;
|
||||
var pageIndex = this.pageIndex;
|
||||
var uniquePrefix = this.uniquePrefix || '';
|
||||
|
||||
function insertDependency(depList) {
|
||||
|
@ -217,7 +219,7 @@ var PartialEvaluator = (function PartialEvaluatorClosure() {
|
|||
if (!font.sent) {
|
||||
var data = font.translated.exportData();
|
||||
|
||||
handler.send('obj', [
|
||||
handler.send('commonobj', [
|
||||
loadedName,
|
||||
'Font',
|
||||
data
|
||||
|
@ -271,7 +273,7 @@ var PartialEvaluator = (function PartialEvaluatorClosure() {
|
|||
image.isNativelySupported(xref, resources)) {
|
||||
// These JPEGs don't need any more processing so we can just send it.
|
||||
fn = 'paintJpegXObject';
|
||||
handler.send('obj', [objId, 'JpegStream', image.getIR()]);
|
||||
handler.send('obj', [objId, pageIndex, 'JpegStream', image.getIR()]);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -287,7 +289,7 @@ var PartialEvaluator = (function PartialEvaluatorClosure() {
|
|||
};
|
||||
var pixels = imgData.data;
|
||||
imageObj.fillRgbaBuffer(pixels, drawWidth, drawHeight);
|
||||
handler.send('obj', [objId, 'Image', imgData]);
|
||||
handler.send('obj', [objId, pageIndex, 'Image', imgData]);
|
||||
}, handler, xref, resources, image, inline);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue