Skip navigation
Aur15
Currently Being Moderated

Writing an image to PDF

Jul 11, 2013 10:44 AM

Hi everybody,

 

I encountered a problem when writing a pdf file in Flash Builder. I need to save some images from jpg/png files, but the method:


pdf.addImage(image, null, 20, 200);

requires the image to be a DisplayObject, which I do not know how to obtain from my jpg/png files.

I would be extremely grateful if you can give me a suggestion. Thank you!

 
Replies
  • Currently Being Moderated
    Jul 12, 2013 1:53 AM   in reply to Aur15

    Hello!

    You don't write what library you are using for export image to PDF, but I can suggest that is AlivePDF.

    If it true and your image is valid png/jpg file in ByteArray you can try to use addImageStream method like that:

     

    pdf.addImageStream(image, ColorSpace.DEVICE_RGB, new Resize(Mode.NONE, Position.LEFT), 0, 0, 20, 200);

     
    |
    Mark as:
  • Currently Being Moderated
    Jul 12, 2013 3:32 AM   in reply to Aur15

    For example, you can load image by using Loader/URLLoader. After this you will have a Bitmap instance with your image. And then you can use addImage(bitmap...).

     
    |
    Mark as:
  • Currently Being Moderated
    Jul 15, 2013 10:55 PM   in reply to Aur15

    pdf.save can performed before pdf.addImage in your code. Maybe this is reason why it don't work.

    Try to put

    var bytes:ByteArray = pdf.save(Method.LOCAL); 

                                            fs.writeBytes(bytes); 

                                            fs.close();

     

    after

    pdf.addImage(image, null, 20, 20);

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points