|
|
@ -45,7 +45,7 @@ PDFJS.getDocument = function getDocument(source) { |
|
|
|
* Proxy to a PDFDocument in the worker thread. Also, contains commonly used |
|
|
|
* Proxy to a PDFDocument in the worker thread. Also, contains commonly used |
|
|
|
* properties that can be read synchronously. |
|
|
|
* properties that can be read synchronously. |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
var PDFDocumentProxy = (function() { |
|
|
|
var PDFDocumentProxy = (function PDFDocumentProxyClosure() { |
|
|
|
function PDFDocumentProxy(pdfInfo, transport) { |
|
|
|
function PDFDocumentProxy(pdfInfo, transport) { |
|
|
|
this.pdfInfo = pdfInfo; |
|
|
|
this.pdfInfo = pdfInfo; |
|
|
|
this.transport = transport; |
|
|
|
this.transport = transport; |
|
|
@ -69,14 +69,14 @@ var PDFDocumentProxy = (function() { |
|
|
|
* @return {Promise} A promise that is resolved with a {PDFPageProxy} |
|
|
|
* @return {Promise} A promise that is resolved with a {PDFPageProxy} |
|
|
|
* object. |
|
|
|
* object. |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
getPage: function(number) { |
|
|
|
getPage: function PDFDocumentProxy_getPage(number) { |
|
|
|
return this.transport.getPage(number); |
|
|
|
return this.transport.getPage(number); |
|
|
|
}, |
|
|
|
}, |
|
|
|
/** |
|
|
|
/** |
|
|
|
* @return {Promise} A promise that is resolved with a lookup table for |
|
|
|
* @return {Promise} A promise that is resolved with a lookup table for |
|
|
|
* mapping named destinations to reference numbers. |
|
|
|
* mapping named destinations to reference numbers. |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
getDestinations: function() { |
|
|
|
getDestinations: function PDFDocumentProxy_getDestinations() { |
|
|
|
var promise = new PDFJS.Promise(); |
|
|
|
var promise = new PDFJS.Promise(); |
|
|
|
var destinations = this.pdfInfo.destinations; |
|
|
|
var destinations = this.pdfInfo.destinations; |
|
|
|
promise.resolve(destinations); |
|
|
|
promise.resolve(destinations); |
|
|
@ -97,7 +97,7 @@ var PDFDocumentProxy = (function() { |
|
|
|
* ... |
|
|
|
* ... |
|
|
|
* ]. |
|
|
|
* ]. |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
getOutline: function() { |
|
|
|
getOutline: function PDFDocumentProxy_getOutline() { |
|
|
|
var promise = new PDFJS.Promise(); |
|
|
|
var promise = new PDFJS.Promise(); |
|
|
|
var outline = this.pdfInfo.outline; |
|
|
|
var outline = this.pdfInfo.outline; |
|
|
|
promise.resolve(outline); |
|
|
|
promise.resolve(outline); |
|
|
@ -109,7 +109,7 @@ var PDFDocumentProxy = (function() { |
|
|
|
* available in the information dictionary and similarly metadata is a |
|
|
|
* available in the information dictionary and similarly metadata is a |
|
|
|
* {Metadata} object with information from the metadata section of the PDF. |
|
|
|
* {Metadata} object with information from the metadata section of the PDF. |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
getMetadata: function() { |
|
|
|
getMetadata: function PDFDocumentProxy_getMetadata() { |
|
|
|
var promise = new PDFJS.Promise(); |
|
|
|
var promise = new PDFJS.Promise(); |
|
|
|
var info = this.pdfInfo.info; |
|
|
|
var info = this.pdfInfo.info; |
|
|
|
var metadata = this.pdfInfo.metadata; |
|
|
|
var metadata = this.pdfInfo.metadata; |
|
|
@ -119,7 +119,7 @@ var PDFDocumentProxy = (function() { |
|
|
|
}); |
|
|
|
}); |
|
|
|
return promise; |
|
|
|
return promise; |
|
|
|
}, |
|
|
|
}, |
|
|
|
destroy: function() { |
|
|
|
destroy: function PDFDocumentProxy_destroy() { |
|
|
|
this.transport.destroy(); |
|
|
|
this.transport.destroy(); |
|
|
|
} |
|
|
|
} |
|
|
|
}; |
|
|
|
}; |
|
|
@ -169,7 +169,7 @@ var PDFPageProxy = (function PDFPageProxyClosure() { |
|
|
|
* @return {PageViewport} Contains 'width' and 'height' properties along |
|
|
|
* @return {PageViewport} Contains 'width' and 'height' properties along |
|
|
|
* with transforms required for rendering. |
|
|
|
* with transforms required for rendering. |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
getViewport: function(scale, rotate) { |
|
|
|
getViewport: function PDFPageProxy_getViewport(scale, rotate) { |
|
|
|
if (arguments.length < 2) |
|
|
|
if (arguments.length < 2) |
|
|
|
rotate = this.rotate; |
|
|
|
rotate = this.rotate; |
|
|
|
return new PDFJS.PageViewport(this.view, scale, rotate, 0, 0); |
|
|
|
return new PDFJS.PageViewport(this.view, scale, rotate, 0, 0); |
|
|
@ -178,7 +178,7 @@ var PDFPageProxy = (function PDFPageProxyClosure() { |
|
|
|
* @return {Promise} A promise that is resolved with an {array} of the |
|
|
|
* @return {Promise} A promise that is resolved with an {array} of the |
|
|
|
* annotation objects. |
|
|
|
* annotation objects. |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
getAnnotations: function() { |
|
|
|
getAnnotations: function PDFPageProxy_getAnnotations() { |
|
|
|
if (this.annotationsPromise) |
|
|
|
if (this.annotationsPromise) |
|
|
|
return this.annotationsPromise; |
|
|
|
return this.annotationsPromise; |
|
|
|
|
|
|
|
|
|
|
@ -198,7 +198,7 @@ var PDFPageProxy = (function PDFPageProxyClosure() { |
|
|
|
* @return {Promise} A promise that is resolved when the page finishes |
|
|
|
* @return {Promise} A promise that is resolved when the page finishes |
|
|
|
* rendering. |
|
|
|
* rendering. |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
render: function(params) { |
|
|
|
render: function PDFPageProxy_render(params) { |
|
|
|
this.renderInProgress = true; |
|
|
|
this.renderInProgress = true; |
|
|
|
|
|
|
|
|
|
|
|
var promise = new Promise(); |
|
|
|
var promise = new Promise(); |
|
|
@ -257,7 +257,7 @@ var PDFPageProxy = (function PDFPageProxyClosure() { |
|
|
|
* For internal use only. |
|
|
|
* For internal use only. |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
startRenderingFromOperatorList: |
|
|
|
startRenderingFromOperatorList: |
|
|
|
function PDFPageWrapper_startRenderingFromOperatorList(operatorList, |
|
|
|
function PDFPageProxy_startRenderingFromOperatorList(operatorList, |
|
|
|
fonts) { |
|
|
|
fonts) { |
|
|
|
var self = this; |
|
|
|
var self = this; |
|
|
|
this.operatorList = operatorList; |
|
|
|
this.operatorList = operatorList; |
|
|
@ -279,7 +279,7 @@ var PDFPageProxy = (function PDFPageProxyClosure() { |
|
|
|
/** |
|
|
|
/** |
|
|
|
* For internal use only. |
|
|
|
* For internal use only. |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
ensureFonts: function PDFPageWrapper_ensureFonts(fonts, callback) { |
|
|
|
ensureFonts: function PDFPageProxy_ensureFonts(fonts, callback) { |
|
|
|
this.stats.time('Font Loading'); |
|
|
|
this.stats.time('Font Loading'); |
|
|
|
// Convert the font names to the corresponding font obj.
|
|
|
|
// Convert the font names to the corresponding font obj.
|
|
|
|
for (var i = 0, ii = fonts.length; i < ii; i++) { |
|
|
|
for (var i = 0, ii = fonts.length; i < ii; i++) { |
|
|
@ -299,7 +299,7 @@ var PDFPageProxy = (function PDFPageProxyClosure() { |
|
|
|
/** |
|
|
|
/** |
|
|
|
* For internal use only. |
|
|
|
* For internal use only. |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
display: function PDFPageWrapper_display(gfx, viewport, callback) { |
|
|
|
display: function PDFPageProxy_display(gfx, viewport, callback) { |
|
|
|
var stats = this.stats; |
|
|
|
var stats = this.stats; |
|
|
|
stats.time('Rendering'); |
|
|
|
stats.time('Rendering'); |
|
|
|
|
|
|
|
|
|
|
@ -331,7 +331,7 @@ var PDFPageProxy = (function PDFPageProxyClosure() { |
|
|
|
/** |
|
|
|
/** |
|
|
|
* Stub for future feature. |
|
|
|
* Stub for future feature. |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
getTextContent: function() { |
|
|
|
getTextContent: function PDFPageProxy_getTextContent() { |
|
|
|
var promise = new PDFJS.Promise(); |
|
|
|
var promise = new PDFJS.Promise(); |
|
|
|
var textContent = 'page text'; // not implemented
|
|
|
|
var textContent = 'page text'; // not implemented
|
|
|
|
promise.resolve(textContent); |
|
|
|
promise.resolve(textContent); |
|
|
@ -340,7 +340,7 @@ var PDFPageProxy = (function PDFPageProxyClosure() { |
|
|
|
/** |
|
|
|
/** |
|
|
|
* Stub for future feature. |
|
|
|
* Stub for future feature. |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
getOperationList: function() { |
|
|
|
getOperationList: function PDFPageProxy_getOperationList() { |
|
|
|
var promise = new PDFJS.Promise(); |
|
|
|
var promise = new PDFJS.Promise(); |
|
|
|
var operationList = { // not implemented
|
|
|
|
var operationList = { // not implemented
|
|
|
|
dependencyFontsID: null, |
|
|
|
dependencyFontsID: null, |
|
|
@ -352,7 +352,7 @@ var PDFPageProxy = (function PDFPageProxyClosure() { |
|
|
|
/** |
|
|
|
/** |
|
|
|
* Destroys resources allocated by the page. |
|
|
|
* Destroys resources allocated by the page. |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
destroy: function() { |
|
|
|
destroy: function PDFPageProxy_destroy() { |
|
|
|
this.destroyed = true; |
|
|
|
this.destroyed = true; |
|
|
|
|
|
|
|
|
|
|
|
if (!this.renderInProgress) { |
|
|
|
if (!this.renderInProgress) { |
|
|
|