PDA

View Full Version : Alivepdf, insert image (dynamic variable)


xmag
09-09-2011, 08:10 AM
Hi!

I want to insert image in a PDF, this works:
[Embed( source="assets/images/mon_image.jpg", mimeType="application/octet-stream" )]
var jpgBytesP:Class;
portPDF.addImageStream(new jpgBytesP() as ByteArray, "DeviceRGB",null, 3, 115, 50, 0);

But I want to place my image URL into a variable (getting in a XML config file) and it doesn't work fine: the image is not displayed in the PDF file.
Here is my code:
landPDF=new PDF(Orientation.LANDSCAPE,Unit.MM,Size.LETTER);
....

imgLdr = new Loader();
imgLdr.contentLoaderInfo.addEventListener(Event.CO MPLETE, ImageLoadComplete);
req = new URLRequest(myImage);
imgLdr.load(req);

function ImageLoadComplete(e : Event):void
{
landPDF.addImage(imgLdr,
new Resize(Mode.NONE,Position.LEFT),
0,0,
100,0,
0,1,false,
ImageFormat.JPG,
100,
Blend.NORMAL, null);
}

no error in debug mode...

thanks for help!

iSynapps
09-09-2011, 05:15 PM
I had same issue some time ago. I solved my problem by loading the image (url:string) and assigning it to a Image() component. Take a look on AlivePDF docs and you will see that the addImage() first element is a DisplayObject and what you're trying to assign into it is a Loader() :P

xmag
09-12-2011, 06:10 AM
Thanks for the reply ;)
Yes, I have seen my error and correct it with imgLdr.content but it still not working.
I will test an url ;)

Tio El
04-20-2012, 04:46 AM
Just wondering did you get this to work? any chance of zipped code. ive been pulling my hair out with this issue. the the only issue im having with alivePDF!!!