In the recent purePDF update I’ve added the getInfo method to the PdfReader class, this allows to extract pdf informations once the document has been parsed.
Share with...
Here’s an example:
var pdf: ByteArray = URLLoader( event.target ).data as ByteArray; var reader: PdfReader = new PdfReader( pdf ); reader.addEventListener( Event.COMPLETE, onReadComplete ); reader.readPdf(); function onReadComplete(event:Event):void { var map: HashMap = reader.getInfo(); for( var iterator: Iterator = map.keySet().iterator(); iterator.hasNext(); ) { var key: String = iterator.next(); trace( key + ": " + map.getValue( key ) ); } }
In this way all the document’s metadata will be traced (Author, Creation Date, Title, Subject, etc..)
In order to extract the field directly simply use:
function onReadComplete(event:Event):void { var map: HashMap = reader.getInfo(); trace( "Author: " + map.getValue( "Author" ) ); trace( "Creator: " + map.getValue( "Creator" ) ); trace( "Title: " + map.getValue( "Title" ) ); }
Download the latest purePDF here.