@ -20,7 +20,9 @@
/ * *
/ * *
* @ typedef { Object } PDFDocumentPropertiesOptions
* @ typedef { Object } PDFDocumentPropertiesOptions
* @ property { string } overlayName - Name / identifier for the overlay
* @ property { string } overlayName - Name / identifier for the overlay .
* @ property { Object } fields - Names and elements of the overlay ' s fields .
* @ property { HTMLButtonElement } closeButton - Button for closing the overlay .
* /
* /
/ * *
/ * *
@ -32,24 +34,12 @@ var PDFDocumentProperties = (function PDFDocumentPropertiesClosure() {
* @ param { PDFDocumentPropertiesOptions } options
* @ param { PDFDocumentPropertiesOptions } options
* /
* /
function PDFDocumentProperties ( options ) {
function PDFDocumentProperties ( options ) {
this . fields = options . fields ;
this . overlayName = options . overlayName ;
this . rawFileSize = 0 ;
this . rawFileSize = 0 ;
this . url = null ;
this . url = null ;
this . pdfDocument = null ;
this . pdfDocument = null ;
this . overlayName = options . overlayName ;
// Set the document property fields.
this . fileNameField = options . fileNameField || null ;
this . fileSizeField = options . fileSizeField || null ;
this . titleField = options . titleField || null ;
this . authorField = options . authorField || null ;
this . subjectField = options . subjectField || null ;
this . keywordsField = options . keywordsField || null ;
this . creationDateField = options . creationDateField || null ;
this . modificationDateField = options . modificationDateField || null ;
this . creatorField = options . creatorField || null ;
this . producerField = options . producerField || null ;
this . versionField = options . versionField || null ;
this . pageCountField = options . pageCountField || null ;
// Bind the event listener for the Close button.
// Bind the event listener for the Close button.
if ( options . closeButton ) {
if ( options . closeButton ) {
@ -125,33 +115,29 @@ var PDFDocumentProperties = (function PDFDocumentPropertiesClosure() {
return ;
return ;
}
}
this . setFileSize ( data . length ) ;
this . setFileSize ( data . length ) ;
this . _updateUI ( this . fileSizeField , this . _parseFileSize ( ) ) ;
this . _updateUI ( this . fields [ 'fileSize' ] , this . _parseFileSize ( ) ) ;
} . bind ( this ) ) ;
} . bind ( this ) ) ;
// Get the document properties.
// Get the document properties.
this . pdfDocument . getMetadata ( ) . then ( function ( data ) {
this . pdfDocument . getMetadata ( ) . then ( function ( data ) {
var fields = [
var content = {
{ field : this . fileNameField ,
'fileName' : getPDFFileNameFromURL ( this . url ) ,
content : getPDFFileNameFromURL ( this . url ) } ,
'fileSize' : this . _parseFileSize ( ) ,
{ field : this . fileSizeField , content : this . _parseFileSize ( ) } ,
'title' : data . info . Title ,
{ field : this . titleField , content : data . info . Title } ,
'author' : data . info . Author ,
{ field : this . authorField , content : data . info . Author } ,
'subject' : data . info . Subject ,
{ field : this . subjectField , content : data . info . Subject } ,
'keywords' : data . info . Keywords ,
{ field : this . keywordsField , content : data . info . Keywords } ,
'creationDate' : this . _parseDate ( data . info . CreationDate ) ,
{ field : this . creationDateField ,
'modificationDate' : this . _parseDate ( data . info . ModDate ) ,
content : this . _parseDate ( data . info . CreationDate ) } ,
'creator' : data . info . Creator ,
{ field : this . modificationDateField ,
'producer' : data . info . Producer ,
content : this . _parseDate ( data . info . ModDate ) } ,
'version' : data . info . PDFFormatVersion ,
{ field : this . creatorField , content : data . info . Creator } ,
'pageCount' : this . pdfDocument . numPages
{ field : this . producerField , content : data . info . Producer } ,
} ;
{ field : this . versionField , content : data . info . PDFFormatVersion } ,
{ field : this . pageCountField , content : this . pdfDocument . numPages }
] ;
// Show the properties in the dialog.
// Show the properties in the dialog.
for ( var item in fields ) {
for ( var identifier in content ) {
var element = fields [ item ] ;
this . _updateUI ( this . fields [ identifier ] , content [ identifier ] ) ;
this . _updateUI ( element . field , element . content ) ;
}
}
} . bind ( this ) ) ;
} . bind ( this ) ) ;
} ,
} ,