Fixing names.
This commit is contained in:
parent
3b2d7ed66d
commit
2c49cab3a1
500
src/api.js
500
src/api.js
@ -1,7 +1,250 @@
|
||||
/* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* vim: set shiftwidth=2 tabstop=2 autoindent cindent expandtab: */
|
||||
|
||||
(function pdfApiWrapper() {
|
||||
PDFJS.getDocument = function getDocument(source) {
|
||||
var promise = new PDFJS.Promise();
|
||||
var transport = new WorkerTransport(promise);
|
||||
if (typeof source === 'string') {
|
||||
// fetch url
|
||||
PDFJS.getPdf(
|
||||
{
|
||||
url: source,
|
||||
progress: function getPDFProgress(evt) {
|
||||
if (evt.lengthComputable)
|
||||
promise.progress({
|
||||
loaded: evt.loaded,
|
||||
total: evt.total
|
||||
});
|
||||
},
|
||||
error: function getPDFError(e) {
|
||||
promise.reject('Unexpected server response of ' +
|
||||
e.target.status + '.');
|
||||
}
|
||||
},
|
||||
function getPDFLoad(data) {
|
||||
transport.sendData(data);
|
||||
});
|
||||
} else {
|
||||
// assuming the source is array, instantiating directly from it
|
||||
transport.sendData(source);
|
||||
}
|
||||
return promise;
|
||||
};
|
||||
|
||||
var PDFDocumentProxy = (function() {
|
||||
function PDFDocumentProxy(pdfInfo, transport) {
|
||||
this.pdfInfo = pdfInfo;
|
||||
this.transport = transport;
|
||||
}
|
||||
PDFDocumentProxy.prototype = {
|
||||
get numPages() {
|
||||
return this.pdfInfo.numPages;
|
||||
},
|
||||
get fingerprint() {
|
||||
return this.pdfInfo.fingerprint;
|
||||
},
|
||||
getPage: function(number) {
|
||||
return this.transport.getPage(number);
|
||||
},
|
||||
getDestinations: function() {
|
||||
var promise = new PDFJS.Promise();
|
||||
var destinations = this.pdfInfo.destinations;
|
||||
promise.resolve(destinations);
|
||||
return promise;
|
||||
},
|
||||
getOutline: function() {
|
||||
var promise = new PDFJS.Promise();
|
||||
var outline = this.pdfInfo.outline;
|
||||
promise.resolve(outline);
|
||||
return promise;
|
||||
},
|
||||
getMetadata: function() {
|
||||
var promise = new PDFJS.Promise();
|
||||
var info = this.pdfInfo.info;
|
||||
var metadata = this.pdfInfo.metadata;
|
||||
promise.resolve({
|
||||
info: info,
|
||||
metadata: metadata ? new PDFJS.Metadata(metadata) : null
|
||||
});
|
||||
return promise;
|
||||
},
|
||||
destroy: function() {
|
||||
this.transport.destroy();
|
||||
}
|
||||
};
|
||||
return PDFDocumentProxy;
|
||||
})();
|
||||
|
||||
var PDFPageProxy = (function PDFPageProxyClosure() {
|
||||
function PDFPageProxy(pageInfo, transport) {
|
||||
this.pageInfo = pageInfo;
|
||||
this.transport = transport;
|
||||
this._stats = new StatTimer();
|
||||
this.objs = transport.objs;
|
||||
}
|
||||
PDFPageProxy.prototype = {
|
||||
get pageNumber() {
|
||||
return this.pageInfo.pageIndex + 1;
|
||||
},
|
||||
get rotate() {
|
||||
return this.pageInfo.rotate;
|
||||
},
|
||||
get stats() {
|
||||
return this._stats;
|
||||
},
|
||||
get ref() {
|
||||
return this.pageInfo.ref;
|
||||
},
|
||||
get view() {
|
||||
return this.pageInfo.view;
|
||||
},
|
||||
getViewport: function(scale, rotate) {
|
||||
if (arguments.length < 2)
|
||||
rotate = this.rotate;
|
||||
return new PDFJS.PageViewport(this.view, scale, rotate, 0, 0);
|
||||
},
|
||||
getAnnotations: function() {
|
||||
var promise = new PDFJS.Promise();
|
||||
var annotations = this.pageInfo.annotations;
|
||||
promise.resolve(annotations);
|
||||
return promise;
|
||||
},
|
||||
render: function(renderContext) {
|
||||
var promise = new Promise();
|
||||
var stats = this.stats;
|
||||
stats.time('Overall');
|
||||
// If there is no displayReadyPromise yet, then the operatorList was never
|
||||
// requested before. Make the request and create the promise.
|
||||
if (!this.displayReadyPromise) {
|
||||
this.displayReadyPromise = new Promise();
|
||||
|
||||
this.stats.time('Page Request');
|
||||
this.transport.messageHandler.send('RenderPageRequest', {
|
||||
pageIndex: this.pageNumber - 1
|
||||
});
|
||||
}
|
||||
|
||||
var callback = (function complete(error) {
|
||||
if (error)
|
||||
promise.reject(error);
|
||||
else
|
||||
promise.resolve();
|
||||
});
|
||||
|
||||
// Once the operatorList and fonts are loaded, do the actual rendering.
|
||||
this.displayReadyPromise.then(
|
||||
function pageDisplayReadyPromise() {
|
||||
var gfx = new CanvasGraphics(renderContext.canvasContext,
|
||||
this.objs, renderContext.textLayer);
|
||||
try {
|
||||
this.display(gfx, renderContext.viewport, callback);
|
||||
} catch (e) {
|
||||
if (callback)
|
||||
callback(e);
|
||||
else
|
||||
error(e);
|
||||
}
|
||||
}.bind(this),
|
||||
function pageDisplayReadPromiseError(reason) {
|
||||
if (callback)
|
||||
callback(reason);
|
||||
else
|
||||
error(reason);
|
||||
}
|
||||
);
|
||||
|
||||
return promise;
|
||||
},
|
||||
|
||||
startRenderingFromOperatorList:
|
||||
function PDFPageWrapper_startRenderingFromOperatorList(operatorList,
|
||||
fonts) {
|
||||
var self = this;
|
||||
this.operatorList = operatorList;
|
||||
|
||||
var displayContinuation = function pageDisplayContinuation() {
|
||||
// Always defer call to display() to work around bug in
|
||||
// Firefox error reporting from XHR callbacks.
|
||||
setTimeout(function pageSetTimeout() {
|
||||
self.displayReadyPromise.resolve();
|
||||
});
|
||||
};
|
||||
|
||||
this.ensureFonts(fonts,
|
||||
function pageStartRenderingFromOperatorListEnsureFonts() {
|
||||
displayContinuation();
|
||||
}
|
||||
);
|
||||
},
|
||||
|
||||
ensureFonts: function PDFPageWrapper_ensureFonts(fonts, callback) {
|
||||
this.stats.time('Font Loading');
|
||||
// Convert the font names to the corresponding font obj.
|
||||
for (var i = 0, ii = fonts.length; i < ii; i++) {
|
||||
fonts[i] = this.objs.objs[fonts[i]].data;
|
||||
}
|
||||
|
||||
// Load all the fonts
|
||||
FontLoader.bind(
|
||||
fonts,
|
||||
function pageEnsureFontsFontObjs(fontObjs) {
|
||||
this.stats.timeEnd('Font Loading');
|
||||
|
||||
callback.call(this);
|
||||
}.bind(this)
|
||||
);
|
||||
},
|
||||
|
||||
display: function PDFPageWrapper_display(gfx, viewport, callback) {
|
||||
var stats = this.stats;
|
||||
stats.time('Rendering');
|
||||
|
||||
gfx.beginDrawing(viewport);
|
||||
|
||||
var startIdx = 0;
|
||||
var length = this.operatorList.fnArray.length;
|
||||
var operatorList = this.operatorList;
|
||||
var stepper = null;
|
||||
if (PDFJS.pdfBug && StepperManager.enabled) {
|
||||
stepper = StepperManager.create(this.pageNumber);
|
||||
stepper.init(operatorList);
|
||||
stepper.nextBreakPoint = stepper.getNextBreakPoint();
|
||||
}
|
||||
|
||||
var self = this;
|
||||
function next() {
|
||||
startIdx =
|
||||
gfx.executeOperatorList(operatorList, startIdx, next, stepper);
|
||||
if (startIdx == length) {
|
||||
gfx.endDrawing();
|
||||
stats.timeEnd('Rendering');
|
||||
stats.timeEnd('Overall');
|
||||
if (callback) callback();
|
||||
}
|
||||
}
|
||||
next();
|
||||
},
|
||||
|
||||
getTextContent: function() {
|
||||
var promise = new PDFJS.Promise();
|
||||
var textContent = 'page text'; // not implemented
|
||||
promise.resolve(textContent);
|
||||
return promise;
|
||||
},
|
||||
getOperationList: function() {
|
||||
var promise = new PDFJS.Promise();
|
||||
var operationList = { // not implemented
|
||||
dependencyFontsID: null,
|
||||
operatorList: null
|
||||
};
|
||||
promise.resolve(operationList);
|
||||
return promise;
|
||||
}
|
||||
};
|
||||
return PDFPageProxy;
|
||||
})();
|
||||
|
||||
var WorkerTransport = (function WorkerTransportClosure() {
|
||||
function WorkerTransport(promise) {
|
||||
this.workerReadyPromise = promise;
|
||||
this.objs = new PDFObjects();
|
||||
@ -92,22 +335,22 @@
|
||||
function WorkerTransport_setupMessageHandler(messageHandler) {
|
||||
this.messageHandler = messageHandler;
|
||||
|
||||
messageHandler.on('getdoc', function transportDoc(data) {
|
||||
messageHandler.on('GetDoc', function transportDoc(data) {
|
||||
var pdfInfo = data.pdfInfo;
|
||||
var pdfDocument = new PdfDocumentWrapper(pdfInfo, this);
|
||||
var pdfDocument = new PDFDocumentProxy(pdfInfo, this);
|
||||
this.pdfDocument = pdfDocument;
|
||||
this.workerReadyPromise.resolve(pdfDocument);
|
||||
}, this);
|
||||
|
||||
messageHandler.on('getpage', function transportPage(data) {
|
||||
messageHandler.on('GetPage', function transportPage(data) {
|
||||
var pageInfo = data.pageInfo;
|
||||
var page = new PdfPageWrapper(pageInfo, this);
|
||||
var page = new PDFPageProxy(pageInfo, this);
|
||||
this.pageCache[pageInfo.pageIndex] = page;
|
||||
var promise = this.pagePromises[pageInfo.pageIndex];
|
||||
promise.resolve(page);
|
||||
}, this);
|
||||
|
||||
messageHandler.on('renderpage', function transportRender(data) {
|
||||
messageHandler.on('RenderPage', function transportRender(data) {
|
||||
var page = this.pageCache[data.pageIndex];
|
||||
var depFonts = data.depFonts;
|
||||
|
||||
@ -149,7 +392,7 @@
|
||||
}
|
||||
}, this);
|
||||
|
||||
messageHandler.on('page_error', function transportError(data) {
|
||||
messageHandler.on('PageError', function transportError(data) {
|
||||
var page = this.pageCache[data.pageNum];
|
||||
if (page.displayReadyPromise)
|
||||
page.displayReadyPromise.reject(data.error);
|
||||
@ -157,7 +400,7 @@
|
||||
error(data.error);
|
||||
}, this);
|
||||
|
||||
messageHandler.on('jpeg_decode', function(data, promise) {
|
||||
messageHandler.on('JpegDecode', function(data, promise) {
|
||||
var imageData = data[0];
|
||||
var components = data[1];
|
||||
if (components != 3 && components != 1)
|
||||
@ -194,7 +437,7 @@
|
||||
},
|
||||
|
||||
sendData: function WorkerTransport_sendData(data) {
|
||||
this.messageHandler.send('getdoc_request', data);
|
||||
this.messageHandler.send('GetDocRequest', data);
|
||||
},
|
||||
|
||||
getPage: function WorkerTransport_getPage(pageNumber, promise) {
|
||||
@ -203,245 +446,10 @@
|
||||
return this.pagePromises[pageIndex];
|
||||
var promise = new PDFJS.Promise('Page ' + pageNumber);
|
||||
this.pagePromises[pageIndex] = promise;
|
||||
this.messageHandler.send('getpage_request', { pageIndex: pageIndex });
|
||||
this.messageHandler.send('GetPageRequest', { pageIndex: pageIndex });
|
||||
return promise;
|
||||
}
|
||||
};
|
||||
function PdfPageWrapper(pageInfo, transport) {
|
||||
this.pageInfo = pageInfo;
|
||||
this.transport = transport;
|
||||
this._stats = new StatTimer();
|
||||
this.objs = transport.objs;
|
||||
}
|
||||
PdfPageWrapper.prototype = {
|
||||
get pageNumber() {
|
||||
return this.pageInfo.pageIndex + 1;
|
||||
},
|
||||
get rotate() {
|
||||
return this.pageInfo.rotate;
|
||||
},
|
||||
get stats() {
|
||||
return this._stats;
|
||||
},
|
||||
get ref() {
|
||||
return this.pageInfo.ref;
|
||||
},
|
||||
get view() {
|
||||
return this.pageInfo.view;
|
||||
},
|
||||
getViewport: function(scale, rotate) {
|
||||
if (arguments.length < 2)
|
||||
rotate = this.rotate;
|
||||
return new PDFJS.PageViewport(this.view, scale, rotate, 0, 0);
|
||||
},
|
||||
getAnnotations: function() {
|
||||
var promise = new PDFJS.Promise();
|
||||
var annotations = this.pageInfo.annotations;
|
||||
promise.resolve(annotations);
|
||||
return promise;
|
||||
},
|
||||
render: function(renderContext) {
|
||||
var promise = new Promise();
|
||||
var stats = this.stats;
|
||||
stats.time('Overall');
|
||||
// If there is no displayReadyPromise yet, then the operatorList was never
|
||||
// requested before. Make the request and create the promise.
|
||||
if (!this.displayReadyPromise) {
|
||||
this.displayReadyPromise = new Promise();
|
||||
return WorkerTransport;
|
||||
|
||||
this.stats.time('Page Request');
|
||||
this.transport.messageHandler.send('renderpage_request', {
|
||||
pageIndex: this.pageNumber - 1
|
||||
});
|
||||
}
|
||||
|
||||
var callback = (function complete(error) {
|
||||
if (error)
|
||||
promise.reject(error);
|
||||
else
|
||||
promise.resolve();
|
||||
});
|
||||
|
||||
// Once the operatorList and fonts are loaded, do the actual rendering.
|
||||
this.displayReadyPromise.then(
|
||||
function pageDisplayReadyPromise() {
|
||||
var gfx = new CanvasGraphics(renderContext.canvasContext,
|
||||
this.objs, renderContext.textLayer);
|
||||
try {
|
||||
this.display(gfx, renderContext.viewport, callback);
|
||||
} catch (e) {
|
||||
if (callback)
|
||||
callback(e);
|
||||
else
|
||||
error(e);
|
||||
}
|
||||
}.bind(this),
|
||||
function pageDisplayReadPromiseError(reason) {
|
||||
if (callback)
|
||||
callback(reason);
|
||||
else
|
||||
error(reason);
|
||||
}
|
||||
);
|
||||
|
||||
return promise;
|
||||
},
|
||||
|
||||
startRenderingFromOperatorList:
|
||||
function PdfPageWrapper_startRenderingFromOperatorList(operatorList,
|
||||
fonts) {
|
||||
var self = this;
|
||||
this.operatorList = operatorList;
|
||||
|
||||
var displayContinuation = function pageDisplayContinuation() {
|
||||
// Always defer call to display() to work around bug in
|
||||
// Firefox error reporting from XHR callbacks.
|
||||
setTimeout(function pageSetTimeout() {
|
||||
self.displayReadyPromise.resolve();
|
||||
});
|
||||
};
|
||||
|
||||
this.ensureFonts(fonts,
|
||||
function pageStartRenderingFromOperatorListEnsureFonts() {
|
||||
displayContinuation();
|
||||
}
|
||||
);
|
||||
},
|
||||
|
||||
ensureFonts: function PdfPageWrapper_ensureFonts(fonts, callback) {
|
||||
this.stats.time('Font Loading');
|
||||
// Convert the font names to the corresponding font obj.
|
||||
for (var i = 0, ii = fonts.length; i < ii; i++) {
|
||||
fonts[i] = this.objs.objs[fonts[i]].data;
|
||||
}
|
||||
|
||||
// Load all the fonts
|
||||
FontLoader.bind(
|
||||
fonts,
|
||||
function pageEnsureFontsFontObjs(fontObjs) {
|
||||
this.stats.timeEnd('Font Loading');
|
||||
|
||||
callback.call(this);
|
||||
}.bind(this)
|
||||
);
|
||||
},
|
||||
|
||||
display: function PdfPageWrapper_display(gfx, viewport, callback) {
|
||||
var stats = this.stats;
|
||||
stats.time('Rendering');
|
||||
|
||||
gfx.beginDrawing(viewport);
|
||||
|
||||
var startIdx = 0;
|
||||
var length = this.operatorList.fnArray.length;
|
||||
var operatorList = this.operatorList;
|
||||
var stepper = null;
|
||||
if (PDFJS.pdfBug && StepperManager.enabled) {
|
||||
stepper = StepperManager.create(this.pageNumber);
|
||||
stepper.init(operatorList);
|
||||
stepper.nextBreakPoint = stepper.getNextBreakPoint();
|
||||
}
|
||||
|
||||
var self = this;
|
||||
function next() {
|
||||
startIdx =
|
||||
gfx.executeOperatorList(operatorList, startIdx, next, stepper);
|
||||
if (startIdx == length) {
|
||||
gfx.endDrawing();
|
||||
stats.timeEnd('Rendering');
|
||||
stats.timeEnd('Overall');
|
||||
if (callback) callback();
|
||||
}
|
||||
}
|
||||
next();
|
||||
},
|
||||
|
||||
getTextContent: function() {
|
||||
var promise = new PDFJS.Promise();
|
||||
var textContent = 'page text'; // not implemented
|
||||
promise.resolve(textContent);
|
||||
return promise;
|
||||
},
|
||||
getOperationList: function() {
|
||||
var promise = new PDFJS.Promise();
|
||||
var operationList = { // not implemented
|
||||
dependencyFontsID: null,
|
||||
operatorList: null
|
||||
};
|
||||
promise.resolve(operationList);
|
||||
return promise;
|
||||
}
|
||||
};
|
||||
|
||||
function PdfDocumentWrapper(pdfInfo, transport) {
|
||||
this.pdfInfo = pdfInfo;
|
||||
this.transport = transport;
|
||||
}
|
||||
PdfDocumentWrapper.prototype = {
|
||||
get numPages() {
|
||||
return this.pdfInfo.numPages;
|
||||
},
|
||||
get fingerprint() {
|
||||
return this.pdfInfo.fingerprint;
|
||||
},
|
||||
getPage: function(number) {
|
||||
return this.transport.getPage(number);
|
||||
},
|
||||
getDestinations: function() {
|
||||
var promise = new PDFJS.Promise();
|
||||
var destinations = this.pdfInfo.destinations;
|
||||
promise.resolve(destinations);
|
||||
return promise;
|
||||
},
|
||||
getOutline: function() {
|
||||
var promise = new PDFJS.Promise();
|
||||
var outline = this.pdfInfo.outline;
|
||||
promise.resolve(outline);
|
||||
return promise;
|
||||
},
|
||||
getMetadata: function() {
|
||||
var promise = new PDFJS.Promise();
|
||||
var info = this.pdfInfo.info;
|
||||
var metadata = this.pdfInfo.metadata;
|
||||
promise.resolve({
|
||||
info: info,
|
||||
metadata: metadata ? new PDFJS.Metadata(metadata) : null
|
||||
});
|
||||
return promise;
|
||||
},
|
||||
destroy: function() {
|
||||
this.transport.destroy();
|
||||
}
|
||||
};
|
||||
|
||||
PDFJS.getDocument = function getDocument(source) {
|
||||
var promise = new PDFJS.Promise();
|
||||
var transport = new WorkerTransport(promise);
|
||||
if (typeof source === 'string') {
|
||||
// fetch url
|
||||
PDFJS.getPdf(
|
||||
{
|
||||
url: source,
|
||||
progress: function getPdfProgress(evt) {
|
||||
if (evt.lengthComputable)
|
||||
promise.progress({
|
||||
loaded: evt.loaded,
|
||||
total: evt.total
|
||||
});
|
||||
},
|
||||
error: function getPdfError(e) {
|
||||
promise.reject('Unexpected server response of ' +
|
||||
e.target.status + '.');
|
||||
}
|
||||
},
|
||||
function getPdfLoad(data) {
|
||||
transport.sendData(data);
|
||||
});
|
||||
} else {
|
||||
// assuming the source is array, instantiating directly from it
|
||||
transport.sendData(source);
|
||||
}
|
||||
return promise;
|
||||
};
|
||||
})();
|
||||
|
||||
|
26
src/core.js
26
src/core.js
@ -311,20 +311,20 @@ var Page = (function PageClosure() {
|
||||
})();
|
||||
|
||||
/**
|
||||
* The `PDFDocModel` holds all the data of the PDF file. Compared to the
|
||||
* The `PDFDocument` holds all the data of the PDF file. Compared to the
|
||||
* `PDFDoc`, this one doesn't have any job management code.
|
||||
* Right now there exists one PDFDocModel on the main thread + one object
|
||||
* Right now there exists one PDFDocument on the main thread + one object
|
||||
* for each worker. If there is no worker support enabled, there are two
|
||||
* `PDFDocModel` objects on the main thread created.
|
||||
* `PDFDocument` objects on the main thread created.
|
||||
*/
|
||||
var PDFDocModel = (function PDFDocModelClosure() {
|
||||
function PDFDocModel(arg, callback) {
|
||||
var PDFDocument = (function PDFDocumentClosure() {
|
||||
function PDFDocument(arg, callback) {
|
||||
if (isStream(arg))
|
||||
init.call(this, arg);
|
||||
else if (isArrayBuffer(arg))
|
||||
init.call(this, new Stream(arg));
|
||||
else
|
||||
error('PDFDocModel: Unknown argument type');
|
||||
error('PDFDocument: Unknown argument type');
|
||||
}
|
||||
|
||||
function init(stream) {
|
||||
@ -350,7 +350,7 @@ var PDFDocModel = (function PDFDocModelClosure() {
|
||||
return true; /* found */
|
||||
}
|
||||
|
||||
PDFDocModel.prototype = {
|
||||
PDFDocument.prototype = {
|
||||
get linearization() {
|
||||
var length = this.stream.length;
|
||||
var linearization = false;
|
||||
@ -411,7 +411,7 @@ var PDFDocModel = (function PDFDocModelClosure() {
|
||||
},
|
||||
// Find the header, remove leading garbage and setup the stream
|
||||
// starting from the header.
|
||||
checkHeader: function PDFDocModel_checkHeader() {
|
||||
checkHeader: function PDFDocument_checkHeader() {
|
||||
var stream = this.stream;
|
||||
stream.reset();
|
||||
if (find(stream, '%PDF-', 1024)) {
|
||||
@ -421,7 +421,7 @@ var PDFDocModel = (function PDFDocModelClosure() {
|
||||
}
|
||||
// May not be a PDF file, continue anyway.
|
||||
},
|
||||
setup: function PDFDocModel_setup(ownerPassword, userPassword) {
|
||||
setup: function PDFDocument_setup(ownerPassword, userPassword) {
|
||||
this.checkHeader();
|
||||
var xref = new XRef(this.stream,
|
||||
this.startXRef,
|
||||
@ -435,7 +435,7 @@ var PDFDocModel = (function PDFDocModelClosure() {
|
||||
// shadow the prototype getter
|
||||
return shadow(this, 'numPages', num);
|
||||
},
|
||||
getDocumentInfo: function PDFDocModel_getDocumentInfo() {
|
||||
getDocumentInfo: function PDFDocument_getDocumentInfo() {
|
||||
var info;
|
||||
if (this.xref.trailer.has('Info')) {
|
||||
var infoDict = this.xref.trailer.get('Info');
|
||||
@ -449,7 +449,7 @@ var PDFDocModel = (function PDFDocModelClosure() {
|
||||
|
||||
return shadow(this, 'getDocumentInfo', info);
|
||||
},
|
||||
getFingerprint: function PDFDocModel_getFingerprint() {
|
||||
getFingerprint: function PDFDocument_getFingerprint() {
|
||||
var xref = this.xref, fileID;
|
||||
if (xref.trailer.has('ID')) {
|
||||
fileID = '';
|
||||
@ -470,10 +470,10 @@ var PDFDocModel = (function PDFDocModelClosure() {
|
||||
|
||||
return shadow(this, 'getFingerprint', fileID);
|
||||
},
|
||||
getPage: function PDFDocModel_getPage(n) {
|
||||
getPage: function PDFDocument_getPage(n) {
|
||||
return this.catalog.getPage(n);
|
||||
}
|
||||
};
|
||||
|
||||
return PDFDocModel;
|
||||
return PDFDocument;
|
||||
})();
|
||||
|
@ -15,7 +15,7 @@ var PDFImage = (function PDFImageClosure() {
|
||||
var colorSpace = dict.get('ColorSpace', 'CS');
|
||||
colorSpace = ColorSpace.parse(colorSpace, xref, res);
|
||||
var numComps = colorSpace.numComps;
|
||||
handler.send('jpeg_decode', [image.getIR(), numComps], function(message) {
|
||||
handler.send('JpegDecode', [image.getIR(), numComps], function(message) {
|
||||
var data = message.data;
|
||||
var stream = new Stream(data, 0, data.length, image.dict);
|
||||
promise.resolve(stream);
|
||||
|
@ -85,10 +85,10 @@ var WorkerMessageHandler = {
|
||||
handler.send('test', data instanceof Uint8Array);
|
||||
});
|
||||
|
||||
handler.on('getdoc_request', function wphSetupDoc(data) {
|
||||
handler.on('GetDocRequest', function wphSetupDoc(data) {
|
||||
// Create only the model of the PDFDoc, which is enough for
|
||||
// processing the content of the pdf.
|
||||
pdfModel = new PDFDocModel(new Stream(data));
|
||||
pdfModel = new PDFDocument(new Stream(data));
|
||||
var doc = {
|
||||
numPages: pdfModel.numPages,
|
||||
fingerprint: pdfModel.fingerprint,
|
||||
@ -97,10 +97,10 @@ var WorkerMessageHandler = {
|
||||
info: pdfModel.info,
|
||||
metadata: pdfModel.catalog.metadata
|
||||
};
|
||||
handler.send('getdoc', {pdfInfo: doc});
|
||||
handler.send('GetDoc', {pdfInfo: doc});
|
||||
});
|
||||
|
||||
handler.on('getpage_request', function wphSetupTest(data) {
|
||||
handler.on('GetPageRequest', function wphSetupTest(data) {
|
||||
var pageNumber = data.pageIndex + 1;
|
||||
var pdfPage = pdfModel.getPage(pageNumber);
|
||||
var page = {
|
||||
@ -110,10 +110,10 @@ var WorkerMessageHandler = {
|
||||
view: pdfPage.view,
|
||||
annotations: pdfPage.getAnnotations()
|
||||
};
|
||||
handler.send('getpage', {pageInfo: page});
|
||||
handler.send('GetPage', {pageInfo: page});
|
||||
});
|
||||
|
||||
handler.on('renderpage_request', function wphSetupPageRequest(data) {
|
||||
handler.on('RenderPageRequest', function wphSetupPageRequest(data) {
|
||||
var pageNum = data.pageIndex + 1;
|
||||
|
||||
|
||||
@ -152,7 +152,7 @@ var WorkerMessageHandler = {
|
||||
};
|
||||
}
|
||||
|
||||
handler.send('page_error', {
|
||||
handler.send('PageError', {
|
||||
pageNum: pageNum,
|
||||
error: e
|
||||
});
|
||||
@ -171,7 +171,7 @@ var WorkerMessageHandler = {
|
||||
}
|
||||
}
|
||||
|
||||
handler.send('renderpage', {
|
||||
handler.send('RenderPage', {
|
||||
pageIndex: data.pageIndex,
|
||||
operatorList: operatorList,
|
||||
depFonts: Object.keys(fonts)
|
||||
|
Loading…
Reference in New Issue
Block a user