Browse Source

PDF.js version 1.0.887

master v1.0.887
Pdf Bot 10 years ago
parent
commit
d4e8fb0856
  1. 2
      bower.json
  2. 126
      build/pdf.combined.js
  3. 18
      build/pdf.js
  4. 112
      build/pdf.worker.js
  5. 2
      package.json

2
bower.json

@ -1,6 +1,6 @@
{ {
"name": "pdfjs-dist", "name": "pdfjs-dist",
"version": "1.0.884", "version": "1.0.887",
"main": [ "main": [
"build/pdf.js", "build/pdf.js",
"build/pdf.worker.js" "build/pdf.worker.js"

126
build/pdf.combined.js

@ -22,8 +22,8 @@ if (typeof PDFJS === 'undefined') {
(typeof window !== 'undefined' ? window : this).PDFJS = {}; (typeof window !== 'undefined' ? window : this).PDFJS = {};
} }
PDFJS.version = '1.0.884'; PDFJS.version = '1.0.887';
PDFJS.build = 'fb6d87c'; PDFJS.build = '878fad4';
(function pdfjsWrapper() { (function pdfjsWrapper() {
// Use strict in our context only - users might not want it // Use strict in our context only - users might not want it
@ -1880,10 +1880,20 @@ var PDFDocumentProxy = (function PDFDocumentProxyClosure() {
/** /**
* @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.
*
* This can be slow for large documents: use getDestination instead
*/ */
getDestinations: function PDFDocumentProxy_getDestinations() { getDestinations: function PDFDocumentProxy_getDestinations() {
return this.transport.getDestinations(); return this.transport.getDestinations();
}, },
/**
* @param {string} id The named destination to get.
* @return {Promise} A promise that is resolved with all information
* of the given named destination.
*/
getDestination: function PDFDocumentProxy_getDestination(id) {
return this.transport.getDestination(id);
},
/** /**
* @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 attachments to their content. * mapping named attachments to their content.
@ -2661,6 +2671,10 @@ var WorkerTransport = (function WorkerTransportClosure() {
return this.messageHandler.sendWithPromise('GetDestinations', null); return this.messageHandler.sendWithPromise('GetDestinations', null);
}, },
getDestination: function WorkerTransport_getDestination(id) {
return this.messageHandler.sendWithPromise('GetDestination', { id: id } );
},
getAttachments: function WorkerTransport_getAttachments() { getAttachments: function WorkerTransport_getAttachments() {
return this.messageHandler.sendWithPromise('GetAttachments', null); return this.messageHandler.sendWithPromise('GetAttachments', null);
}, },
@ -9628,6 +9642,38 @@ var Catalog = (function CatalogClosure() {
} }
return shadow(this, 'destinations', dests); return shadow(this, 'destinations', dests);
}, },
getDestination: function Catalog_getDestination(destinationId) {
function fetchDestination(dest) {
return isDict(dest) ? dest.get('D') : dest;
}
var xref = this.xref;
var dest, nameTreeRef, nameDictionaryRef;
var obj = this.catDict.get('Names');
if (obj && obj.has('Dests')) {
nameTreeRef = obj.getRaw('Dests');
} else if (this.catDict.has('Dests')) {
nameDictionaryRef = this.catDict.get('Dests');
}
if (nameDictionaryRef) {
// reading simple destination dictionary
obj = nameDictionaryRef;
obj.forEach(function catalogForEach(key, value) {
if (!value) {
return;
}
if (key === destinationId) {
dest = fetchDestination(value);
}
});
}
if (nameTreeRef) {
var nameTree = new NameTree(nameTreeRef, xref);
dest = fetchDestination(nameTree.get(destinationId));
}
return dest;
},
get attachments() { get attachments() {
var xref = this.xref; var xref = this.xref;
var attachments = null, nameTreeRef; var attachments = null, nameTreeRef;
@ -10529,6 +10575,76 @@ var NameTree = (function NameTreeClosure() {
} }
} }
return dict; return dict;
},
get: function NameTree_get(destinationId) {
if (!this.root) {
return null;
}
var xref = this.xref;
var kidsOrNames = xref.fetchIfRef(this.root);
var loopCount = 0;
var MAX_NAMES_LEVELS = 10;
var l, r, m;
// Perform a binary search to quickly find the entry that
// contains the named destination we are looking for.
while (kidsOrNames.has('Kids')) {
loopCount++;
if (loopCount > MAX_NAMES_LEVELS) {
warn('Search depth limit for named destionations has been reached.');
return null;
}
var kids = kidsOrNames.get('Kids');
if (!isArray(kids)) {
return null;
}
l = 0;
r = kids.length - 1;
while (l <= r) {
m = (l + r) >> 1;
var kid = xref.fetchIfRef(kids[m]);
var limits = kid.get('Limits');
if (destinationId < limits[0]) {
r = m - 1;
} else if (destinationId > limits[1]) {
l = m + 1;
} else {
kidsOrNames = xref.fetchIfRef(kids[m]);
break;
}
}
if (l > r) {
return null;
}
}
// If we get here, then we have found the right entry. Now
// go through the named destinations in the Named dictionary
// until we find the exact destination we're looking for.
var names = kidsOrNames.get('Names');
if (isArray(names)) {
// Perform a binary search to reduce the lookup time.
l = 0;
r = names.length - 2;
while (l <= r) {
// Check only even indices (0, 2, 4, ...) because the
// odd indices contain the actual D array.
m = (l + r) & ~1;
if (destinationId < names[m]) {
r = m - 2;
} else if (destinationId > names[m]) {
l = m + 2;
} else {
return xref.fetchIfRef(names[m + 1]);
}
}
}
return null;
} }
}; };
return NameTree; return NameTree;
@ -39758,6 +39874,12 @@ var WorkerMessageHandler = PDFJS.WorkerMessageHandler = {
} }
); );
handler.on('GetDestination',
function wphSetupGetDestination(data) {
return pdfManager.ensureCatalog('getDestination', [ data.id ]);
}
);
handler.on('GetAttachments', handler.on('GetAttachments',
function wphSetupGetAttachments(data) { function wphSetupGetAttachments(data) {
return pdfManager.ensureCatalog('attachments'); return pdfManager.ensureCatalog('attachments');

18
build/pdf.js

@ -22,8 +22,8 @@ if (typeof PDFJS === 'undefined') {
(typeof window !== 'undefined' ? window : this).PDFJS = {}; (typeof window !== 'undefined' ? window : this).PDFJS = {};
} }
PDFJS.version = '1.0.884'; PDFJS.version = '1.0.887';
PDFJS.build = 'fb6d87c'; PDFJS.build = '878fad4';
(function pdfjsWrapper() { (function pdfjsWrapper() {
// Use strict in our context only - users might not want it // Use strict in our context only - users might not want it
@ -1880,10 +1880,20 @@ var PDFDocumentProxy = (function PDFDocumentProxyClosure() {
/** /**
* @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.
*
* This can be slow for large documents: use getDestination instead
*/ */
getDestinations: function PDFDocumentProxy_getDestinations() { getDestinations: function PDFDocumentProxy_getDestinations() {
return this.transport.getDestinations(); return this.transport.getDestinations();
}, },
/**
* @param {string} id The named destination to get.
* @return {Promise} A promise that is resolved with all information
* of the given named destination.
*/
getDestination: function PDFDocumentProxy_getDestination(id) {
return this.transport.getDestination(id);
},
/** /**
* @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 attachments to their content. * mapping named attachments to their content.
@ -2705,6 +2715,10 @@ var WorkerTransport = (function WorkerTransportClosure() {
return this.messageHandler.sendWithPromise('GetDestinations', null); return this.messageHandler.sendWithPromise('GetDestinations', null);
}, },
getDestination: function WorkerTransport_getDestination(id) {
return this.messageHandler.sendWithPromise('GetDestination', { id: id } );
},
getAttachments: function WorkerTransport_getAttachments() { getAttachments: function WorkerTransport_getAttachments() {
return this.messageHandler.sendWithPromise('GetAttachments', null); return this.messageHandler.sendWithPromise('GetAttachments', null);
}, },

112
build/pdf.worker.js vendored

@ -22,8 +22,8 @@ if (typeof PDFJS === 'undefined') {
(typeof window !== 'undefined' ? window : this).PDFJS = {}; (typeof window !== 'undefined' ? window : this).PDFJS = {};
} }
PDFJS.version = '1.0.884'; PDFJS.version = '1.0.887';
PDFJS.build = 'fb6d87c'; PDFJS.build = '878fad4';
(function pdfjsWrapper() { (function pdfjsWrapper() {
// Use strict in our context only - users might not want it // Use strict in our context only - users might not want it
@ -3519,6 +3519,38 @@ var Catalog = (function CatalogClosure() {
} }
return shadow(this, 'destinations', dests); return shadow(this, 'destinations', dests);
}, },
getDestination: function Catalog_getDestination(destinationId) {
function fetchDestination(dest) {
return isDict(dest) ? dest.get('D') : dest;
}
var xref = this.xref;
var dest, nameTreeRef, nameDictionaryRef;
var obj = this.catDict.get('Names');
if (obj && obj.has('Dests')) {
nameTreeRef = obj.getRaw('Dests');
} else if (this.catDict.has('Dests')) {
nameDictionaryRef = this.catDict.get('Dests');
}
if (nameDictionaryRef) {
// reading simple destination dictionary
obj = nameDictionaryRef;
obj.forEach(function catalogForEach(key, value) {
if (!value) {
return;
}
if (key === destinationId) {
dest = fetchDestination(value);
}
});
}
if (nameTreeRef) {
var nameTree = new NameTree(nameTreeRef, xref);
dest = fetchDestination(nameTree.get(destinationId));
}
return dest;
},
get attachments() { get attachments() {
var xref = this.xref; var xref = this.xref;
var attachments = null, nameTreeRef; var attachments = null, nameTreeRef;
@ -4420,6 +4452,76 @@ var NameTree = (function NameTreeClosure() {
} }
} }
return dict; return dict;
},
get: function NameTree_get(destinationId) {
if (!this.root) {
return null;
}
var xref = this.xref;
var kidsOrNames = xref.fetchIfRef(this.root);
var loopCount = 0;
var MAX_NAMES_LEVELS = 10;
var l, r, m;
// Perform a binary search to quickly find the entry that
// contains the named destination we are looking for.
while (kidsOrNames.has('Kids')) {
loopCount++;
if (loopCount > MAX_NAMES_LEVELS) {
warn('Search depth limit for named destionations has been reached.');
return null;
}
var kids = kidsOrNames.get('Kids');
if (!isArray(kids)) {
return null;
}
l = 0;
r = kids.length - 1;
while (l <= r) {
m = (l + r) >> 1;
var kid = xref.fetchIfRef(kids[m]);
var limits = kid.get('Limits');
if (destinationId < limits[0]) {
r = m - 1;
} else if (destinationId > limits[1]) {
l = m + 1;
} else {
kidsOrNames = xref.fetchIfRef(kids[m]);
break;
}
}
if (l > r) {
return null;
}
}
// If we get here, then we have found the right entry. Now
// go through the named destinations in the Named dictionary
// until we find the exact destination we're looking for.
var names = kidsOrNames.get('Names');
if (isArray(names)) {
// Perform a binary search to reduce the lookup time.
l = 0;
r = names.length - 2;
while (l <= r) {
// Check only even indices (0, 2, 4, ...) because the
// odd indices contain the actual D array.
m = (l + r) & ~1;
if (destinationId < names[m]) {
r = m - 2;
} else if (destinationId > names[m]) {
l = m + 2;
} else {
return xref.fetchIfRef(names[m + 1]);
}
}
}
return null;
} }
}; };
return NameTree; return NameTree;
@ -33649,6 +33751,12 @@ var WorkerMessageHandler = PDFJS.WorkerMessageHandler = {
} }
); );
handler.on('GetDestination',
function wphSetupGetDestination(data) {
return pdfManager.ensureCatalog('getDestination', [ data.id ]);
}
);
handler.on('GetAttachments', handler.on('GetAttachments',
function wphSetupGetAttachments(data) { function wphSetupGetAttachments(data) {
return pdfManager.ensureCatalog('attachments'); return pdfManager.ensureCatalog('attachments');

2
package.json

@ -1,6 +1,6 @@
{ {
"name": "pdfjs-dist", "name": "pdfjs-dist",
"version": "1.0.884", "version": "1.0.887",
"description": "Generic build of Mozilla's PDF.js library.", "description": "Generic build of Mozilla's PDF.js library.",
"keywords": [ "keywords": [
"Mozilla", "Mozilla",

Loading…
Cancel
Save