How to add BitmapData (graphic as byte array) to PDF

If you are a C/C++/C# developer and have any questions about using our products from your application here is the place to post them.
Post Reply
nathand
Posts: 1
Joined: Tue Apr 28 2009

How to add BitmapData (graphic as byte array) to PDF

Post by nathand » Wed Apr 29 2009

Following the examples in the docs, I can add a graphic to a PDF that I'm creating by setting the "FileName" attribute to a jpg on disk:

Code: Select all

oPicture.Attribute("FileName").Value = @"c:\temp\test2.jpg";
However, when I use the "BitmapData" attribute, and set it to a byte array, it always fails when I save the page. I've tried several image formats, with the same results.

Code: Select all

using (MemoryStream msPic = new MemoryStream())
{
    m_img.Save(msPic, System.Drawing.Imaging.ImageFormat.Jpeg);
    oPicture.Attribute("BitmapData").Value = msPic.ToArray();  // GetBuffer() gives the same results
    msPic.Close();
}
Error: "Attempted to divide by zero" in Amyuni.PDFCreator.IacDocument.SavePageNumber.

I'm using PDF Creator v3.0.

Thanks,
Nathan

Devteam
Posts: 115
Joined: Fri Oct 14 2005
Location: Montreal
Contact:

Re: How to add BitmapData (graphic as byte array) to PDF

Post by Devteam » Fri Sep 12 2014

An answer for this question can be found in the following post:

http://www.amyuni.com/forum/viewtopic.p ... 2796#p8843

Post Reply