* Right now there exists one PDFDocModel 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.
- * TODO: Refactor the internal object structure, such that there is no
- * need for the `PDFDocModel` anymore and there is only one object on the
- * main thread and not one entire copy on each worker instance.
*/
var PDFDocModel = (function PDFDocModelClosure() {
function PDFDocModel(arg, callback) {
this.data = data;
this.stream = stream;
- this.pdf = new PDFDocModel(stream);
- this.fingerprint = this.pdf.getFingerprint();
- this.catalog = this.pdf.catalog;
+ this.pdfModel = new PDFDocModel(stream);
+ this.fingerprint = this.pdfModel.getFingerprint();
+ this.catalog = this.pdfModel.catalog;
this.objs = new PDFObjects();
this.pageCache = [];
},
get numPages() {
- return this.pdf.numPages;
+ return this.pdfModel.numPages;
},
startRendering: function pdfDocStartRendering(page) {
if (this.pageCache[n])
return this.pageCache[n];
- var page = this.pdf.getPage(n);
+ var page = this.pdfModel.getPage(n);
// Add a reference to the objects such that Page can forward the reference
// to the CanvasGraphics and so on.
page.objs = this.objs;
var WorkerMessageHandler = {
setup: function wphSetup(handler) {
- var pdfDoc = null;
+ var pdfModel = null;
handler.on('test', function wphSetupTest(data) {
handler.send('test', data instanceof Uint8Array);
handler.on('doc', function wphSetupDoc(data) {
// Create only the model of the PDFDoc, which is enough for
// processing the content of the pdf.
- pdfDoc = new PDFDocModel(new Stream(data));
+ pdfModel = new PDFDocModel(new Stream(data));
});
handler.on('page_request', function wphSetupPageRequest(pageNum) {
var dependency = [];
var IRQueue = null;
try {
- var page = pdfDoc.getPage(pageNum);
+ var page = pdfModel.getPage(pageNum);
// Pre compile the pdf page and fetch the fonts/images.
IRQueue = page.getIRQueue(handler, dependency);
} catch (e) {