Hi
This AddImage is driving me crazy too.
I have the same requirements as Merksim : reasonably High DP(not necessarily 400Dpi though)
I followed Aciusia’s reco and modified the imageElement accordingly.
After what I used the following code to add images to the pdf pages
byte[]img;
//After generating a 2970*2100 img, I add it as an image to the current page
currentPage.addImage(img, 0, 0, 2100, 2970, mmToPoints(210), mmToPoints(297));
// I Modified the AddImage to be able to set the new Width and new Height.(Note: I use a utility to convert mm to Points(the physical unit. not the pixels)
public void addImage(Byte[] myImage, int X, int Y, int imageHeight, int imageWidth, int newHeight, int newWidth)
{
try
{
imageElement objImage = new imageElement(myImage, X, Y, imageHeight, imageWidth,newHeight,newWidth);
_elements.Add(objImage);
objImage = null;
}
catch (pdfImageNotFoundException ex)
{
throw new pdfImageNotFoundException(ex.Message, ex);
}
catch (pdfImageIOException ex)
{
throw new pdfImageIOException(ex.Message, ex);
}
Debug.Log("addedIMage");
}
The result pretty bad : Image resolution is pretty low… and of course it doesn’t read in Acrobat. It works in preview on my mac tough.
Strangely I get better result when I do that:
byte[]img;
currentPage.addImage(img, 0, 0, mmToPoints(210), mmToPoints(297));
public void addImage(Byte[] myImage, int X, int Y, int imageHeight, int imageWidth)
{
try
{
imageElement objImage = new imageElement(myImage, X, Y, imageHeight, imageWidth,imageHeight,imageWidth);
_elements.Add(objImage);
objImage = null;
}
catch (pdfImageNotFoundException ex)
{
throw new pdfImageNotFoundException(ex.Message, ex);
}
catch (pdfImageIOException ex)
{
throw new pdfImageIOException(ex.Message, ex);
}
Debug.Log("addedIMage");
}
The resolution is still pretty bad but I can open it in Acrobat…
@Everyone Any idea?