I'm trying to use PurePDF to gather some information inside a PDF file, but can't manage to have PurePDF read it.
Whenever PurePDF tries to read any pdf, it says it can't find its header, I tried debugging it and noticed the string read from bytearray are coming as japanese characters! I have tried changing the endian of my pdf's bytearray before passing it to PurePDF, but didn't change anything.
The pdf file is ok as I can see the "%PDF-" header whenever I open it as text, but for some reason actionscript is getting wrong charcodes so PurePDF just can't work at all.
Any ideas?
Thanks.
Update: I'm not a bytearray specialist, but I decided to man it and follow the code execution through the debugger, and found out it was using readInt() to get the characters, I just rewrote it to readByte() and now it is reading the PDF! I'm still to see if the features will work... Can anyone who is more into low-level programming explain me what might be happening? I don't think the project is broken in the svn
This is the code I have been using, I think it is quite straightforward:
private function loadPdf():void
{
var loader:URLLoader=new URLLoader();
loader.dataFormat=URLLoaderDataFormat.BINARY;
loader.addEventListener(Event.COMPLETE, onLoadComplete);
loader.load(new URLRequest(PDF_FILE));
}
protected function onLoadComplete(event:Event):void
{
var data:ByteArray = URLLoader(event.target).data as ByteArray;
pdfReader = new PdfReader(data);
pdfReader.readPdf();
}