Hi,
I'm using Aspose.pdf
and got stuck while adding an image of the resolution 1024x768 pixels to a
pdf. The problem is that when opening the generated pdf, I get an error
message: ‘insufficient data for an image’.
I found
this very strange since I’ve had no problems adding images before. After
testing some resolution combinations, I have come to the conclusion that the
error also appears when the image width is 1024 pixels or the image height is
768 pixels.
When running the code below, I get the error on pages 2, 4, 5, 6 and 8. I have also tried viewing the pdf in some different versions of Adobe Reader (7.0.0 , 9.0.0, 9.1.3 and 9.2.0) and the problem persists.
My code:
Pdf pdf = new Pdf();
pdf.setIsLandscape(true);
for(int w =1020; w<1029;w+=4){
for(int h =764; h<775; h+=4){
System.out.println("trying: " + w + "x"+h);
Section sec = pdf.getSections().add();
Image image = new aspose.pdf.Image(sec);
sec.getParagraphs().add(image);
image.getImageInfo().setSystemImage(getImage(w,h));
}
}
try{
pdf.save("test.pdf");
System.out.println("pdf written");
}catch(RuntimeException e){
JOptionPane.showMessageDialog(null, e.getMessage(), "Error saving", JOptionPane.ERROR_MESSAGE);
e.printStackTrace();
}
Am I doing something wrong, or can anyone reproduce this error?
Thanks and best regards,
Mikael
<span style=“font-size: 10pt; line-height: 115%; font-family: “Courier New”; color: black;”><o:p></o:p>