Error adding 1024x768 images

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>

Hello Mikael,

Can you please share the image file that you're using so that we can test the scenario at our end. Because, during my testing, I'm unable to notice any problem when I've used the image files with following dimensions.

1397 x 686 922 x 554 1296 x 1632

If possible, can you please share the resultant PDF that you've generated.

We apologize for your inconvenience.

Hi,


The problem occurs when the resolution is 1024x768, 1024xN or Nx768, where N seems to be any number. For instance the resolution 1024x100 will not work, but both 1023x100 and 1025x100 works.


I have attached my source code that generates and tests images with different resolutions, the resulting pdf, and also a test image. The program must be run with extended memory allocation (-Xmx256m) otherwise it will throw an out of memory exception. In the current configuration my program loops through the following resolutions:

1020x764, 1020x768, 1020x772

1024x764, 1024x768, 1024x772

1028x764, 1028x768, 1028x772

(The resolutions that will not work are marked with red)

I hope this will help you locate the problem.

Hello Mikael,

Thanks for sharing the reosurce files.

I have tested the scenario and I’m able to reproduce the same problem. I have logged it in our issue tracking system as PDFJAVA-15185. We will investigate this issue in details and will keep you updated on the status of a correction. <?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

We apologize for your inconvenience.

The issues you have found earlier (filed as 15164;15185) have been fixed in this update.


This message was posted using Notification2Forum from Downloads module by aspose.notifier.