mirror of
https://github.com/zen-browser/pdf.js.git
synced 2025-07-09 09:45:42 +02:00
Adds basic PDF info
This commit is contained in:
parent
f76adca471
commit
1f56d242ff
2 changed files with 19 additions and 1 deletions
15
src/core.js
15
src/core.js
|
@ -495,6 +495,17 @@ var PDFDocument = (function PDFDocumentClosure() {
|
||||||
if (find(stream, '%PDF-', 1024)) {
|
if (find(stream, '%PDF-', 1024)) {
|
||||||
// Found the header, trim off any garbage before it.
|
// Found the header, trim off any garbage before it.
|
||||||
stream.moveStart();
|
stream.moveStart();
|
||||||
|
// Reading file format version
|
||||||
|
var MAX_VERSION_LENGTH = 12;
|
||||||
|
var version = '', ch;
|
||||||
|
while ((ch = stream.getChar()) > ' ') {
|
||||||
|
if (version.length >= MAX_VERSION_LENGTH) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
version += ch;
|
||||||
|
}
|
||||||
|
// removing "%PDF-"-prefix
|
||||||
|
this.pdfFormatVersion = version.substring(5);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// May not be a PDF file, continue anyway.
|
// May not be a PDF file, continue anyway.
|
||||||
|
@ -519,7 +530,9 @@ var PDFDocument = (function PDFDocumentClosure() {
|
||||||
if (this.xref.trailer.has('Info')) {
|
if (this.xref.trailer.has('Info')) {
|
||||||
var infoDict = this.xref.trailer.get('Info');
|
var infoDict = this.xref.trailer.get('Info');
|
||||||
|
|
||||||
docInfo = {};
|
docInfo = {
|
||||||
|
PDFFormatVersion: this.pdfFormatVersion
|
||||||
|
};
|
||||||
var validEntries = DocumentInfoValidators.entries;
|
var validEntries = DocumentInfoValidators.entries;
|
||||||
// Only fill the document info with valid entries from the spec.
|
// Only fill the document info with valid entries from the spec.
|
||||||
for (var key in validEntries) {
|
for (var key in validEntries) {
|
||||||
|
|
|
@ -1277,6 +1277,11 @@ var PDFView = {
|
||||||
self.documentInfo = info;
|
self.documentInfo = info;
|
||||||
self.metadata = metadata;
|
self.metadata = metadata;
|
||||||
|
|
||||||
|
// Provides some basic debug information
|
||||||
|
console.log('PDF ' + pdfDocument.fingerprint + ' [' +
|
||||||
|
info.PDFFormatVersion + ' ' + (info.Producer || '-') +
|
||||||
|
' / ' + (info.Creator || '-') + ']');
|
||||||
|
|
||||||
var pdfTitle;
|
var pdfTitle;
|
||||||
if (metadata) {
|
if (metadata) {
|
||||||
if (metadata.has('dc:title'))
|
if (metadata.has('dc:title'))
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue