1
0
Fork 0
mirror of https://github.com/mozilla/pdf.js.git synced 2025-04-26 01:58:06 +02:00

Now also fetch 'Document Info Dictionary', and expose 'raw' metadata attributes

This commit is contained in:
Saebekassebil 2012-03-26 23:48:04 +02:00
parent ab198e89cc
commit edc1694620
3 changed files with 29 additions and 28 deletions

View file

@ -587,13 +587,15 @@ var PDFDocModel = (function PDFDocModelClosure() {
this.mainXRefEntriesOffset);
this.xref = xref;
this.catalog = new Catalog(xref);
if (xref.trailer && xref.trailer.has('ID')) {
var fileID = '';
var id = xref.fetchIfRef(xref.trailer.get('ID'))[0];
id.split('').forEach(function(el) {
fileID += Number(el.charCodeAt(0)).toString(16);
});
this.fileID = fileID;
if (xref.trailer) {
if (xref.trailer.has('ID')) {
var fileID = '';
var id = xref.fetchIfRef(xref.trailer.get('ID'))[0];
id.split('').forEach(function(el) {
fileID += Number(el.charCodeAt(0)).toString(16);
});
this.fileID = fileID;
}
}
},
get numPages() {
@ -602,6 +604,11 @@ var PDFDocModel = (function PDFDocModelClosure() {
// shadow the prototype getter
return shadow(this, 'numPages', num);
},
getDocumentInfo: function pdfDocGetDocumentInfo() {
if (this.xref.trailer.has('Info')) {
return this.xref.fetch(this.xref.trailer.get('Info'));
}
},
getFingerprint: function pdfDocGetFingerprint() {
if (this.fileID) {
return this.fileID;
@ -645,6 +652,7 @@ var PDFDoc = (function PDFDocClosure() {
this.stream = stream;
this.pdfModel = new PDFDocModel(stream);
this.fingerprint = this.pdfModel.getFingerprint();
this.info = this.pdfModel.getDocumentInfo();
this.catalog = this.pdfModel.catalog;
this.objs = new PDFObjects();