문제

Hey so I am trying to create an air app that generates a PDF for the user to save but am running into issues with PurePDF. Whenever I run the ImageElement.getInstance() method I am returned a runtime error:

Error: Error #2030: End of file was encountered. at flash.utils::ByteArray/readUnsignedByte()

I am still just in the testing stage and am not evening doing anything crazy. This is what my code looks like:

var bd:BitmapData = new BitmapData( 1024,768 );
bd.draw(pdfClip); //A simple movieclip on the stage containing an image
var bytes:ByteArray = bd.getPixels(new Rectangle(1024,768));
var image:ImageElement = ImageElement.getInstance( bytes );

I would be grateful if anyone that has used purePDF can offer any advice, the documentation is extremely limiting.

도움이 되었습니까?

해결책

You should use the "getBitmapDataInstance" instead, because the "getInstance" method is expecting a png encoded bytearray.

ImageElement.getBitmapDataInstance( bitmap );

see also this example: https://code.google.com/p/purepdf/source/browse/examples/src/ImageBitmapData.as

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top