Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds basic PDF info #2346

Merged
merged 1 commit into from
Nov 29, 2012
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion src/core.js
Original file line number Diff line number Diff line change
Expand Up @@ -495,6 +495,17 @@ var PDFDocument = (function PDFDocumentClosure() {
if (find(stream, '%PDF-', 1024)) {
// Found the header, trim off any garbage before it.
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;
}
// May not be a PDF file, continue anyway.
Expand All @@ -519,7 +530,9 @@ var PDFDocument = (function PDFDocumentClosure() {
if (this.xref.trailer.has('Info')) {
var infoDict = this.xref.trailer.get('Info');

docInfo = {};
docInfo = {
PDFFormatVersion: this.pdfFormatVersion
};
var validEntries = DocumentInfoValidators.entries;
// Only fill the document info with valid entries from the spec.
for (var key in validEntries) {
Expand Down
5 changes: 5 additions & 0 deletions web/viewer.js
Original file line number Diff line number Diff line change
Expand Up @@ -1277,6 +1277,11 @@ var PDFView = {
self.documentInfo = info;
self.metadata = metadata;

// Provides some basic debug information
console.log('PDF ' + pdfDocument.fingerprint + ' [' +
info.PDFFormatVersion + ' ' + (info.Producer || '-') +
' / ' + (info.Creator || '-') + ']');

var pdfTitle;
if (metadata) {
if (metadata.has('dc:title'))
Expand Down