Menu:

Sponsor

Discover Master of Alchemy, our first iPad/iPhone and iPod touch game!

Follow Me

 

Forum's topics

Latest Files

Archives

Top Rated

Categories

Photo Gallery


Alessandro Crugnola on May 28, 2010 in actionscript , purePDF

Read pdf metadata with purePDF

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.

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.

 

Bookmark and Share

 

Tags: Metadata , PDF , PdfReader , purepdf 

 

1 comments
I'm not able to use this code (cf. http://code.google.com/p/purepdf/issues/detail?id=4). Can you explain what exactly is "event.target" because if i load a classique urlrequest, i have the same error i explain in google issue... Thanks in advance! sam


Post a comment

(If you haven't left a comment here before, you may need to be approved by the site owner before your comment will appear. Until then, it won't appear on the entry. Thanks for waiting.)


Type the characters you see in the picture above.





 

TrackBacks

TrackBack URL for this entry: http://www.sephiroth.it/cgi-bin/mt/mt-tb.cgi/295