Free Support Forum - aspose.com

Problem with creating images

Hey,
I’ve downloaded latest version of Aspose Pdf - 2.5.0.
I have problems with creating images in PDF.

1. When I try to create image from web url following message is printed:
“file create error!” and CPU usage is 99% all the time.
Using version 2.4.0 the same code works ok.

2. Is it possible to attach image that is dynamically created by servlet?
In version 2.4.0 when I try to do something like this:
image.getImageInfo().setFile(“http://localhost:8080/app/imageProviderl?width=150&height=100”);
I get exception "format is not supported"

3. Is it possible to create image from stream in version 2.5.0?
It seems that BinaryFileStream(byte[] arr)

doesn’t work.
Also invoking BinaryFileStream.write(byte b) results in exception "java.lang.UnsupportedOperationException: This stream can’t be wrote"

The only way I could create image in version 2.5.0 is from local file.

I will appreciate any help. Thanks
Maciek


Hello Maciek,

Sorry for replying you late.

I've tested all the scenario and I'm able to notice the problems. For the sake of correction, I've logged them in our issue tracking system. We will look into the details of these problems and will keep updated with the status of correction.

1. When I try to create image from web url following message is printed: "file create error!" and CPU usage is 99% all the time.

I've logged it as PDFJAVA-14913

2. invoking BinaryFileStream.write(byte b) results in exception "java.lang.UnsupportedOperationException: This stream can't be wrote"

I've logged it as PDFJAVA-14920

3. It seems that BinaryFileStream(byte[] arr) doesn't work.
I've logged it as PDFJAVA-14921

Regarding the issue "Is it possible to attach image that is dynamically created by servlet? " I think once the issue PDFJAVA-14921, you can export the image from servlet and use the BinaryFileStream object to add an image to PDF document.

Please spare us little time. Once we've some definite information regarding their resolution, we would be pleased to update you with the appropriate status.

Your patience and comprehension is greatly appreciated in this regard.

We apologize for your inconvenience.

Thank you for your answer.
Is there any workaround for this problems? How can I now create image from memory?

What is ETA of fixing this bugs?
We are consider buying aspose.pdf in our company but we really need this functionality.

Regards,
Maciek

Hello Maciek,

Thanks for your interest in our products.

As per your requirements, you need to add an image from Memory into PDF document and I'm afraid currently BinaryFileStream object is not working correctly. I've tried number of scenarios but I'm afraid currently no workaround can fulfill your requirements.

Regarding the ETA of previously reported issues, we need to look into the details of these problems and before we've analyzed them, I'm afraid we might not be able to share the ETA information.

Please be patient. Your cooperation and comprehension is greatly appreciated in this regard.

We apologize for your inconvenience.

For now we will try to use version 2.4.0. In this version I can add images from memory.

But how can I get starting page number of each section in version 2.4.0? Method section.getStartingPageNumber() doesn’t work.

Thanks for your replies.
Maciek

Hello Maciek,

Please try using the attached hotfix for Aspose.Pdf for Java 2.4.3 and as per my observation, its returning the correct value for Section.getStartingPageNumber(...). In case you still face any problem or you've any further query, please feel free to contact.

We apologize for your inconvenience.

Hello,
Thank you for the fix. I tried to use it but with no success.
Maybe I’m using it wrong. Here is my code snippet.

Pdf pdf1 = new Pdf();

Section sec1 = new Section(pdf1);
pdf1.getSections().add(sec1);

Table table1 = new Table(sec1);
sec1.getParagraphs().add(table1);

for (int i = 0; i < 200; i++) {
Row row = table1.getRows().add();
row.getCells().add(i + “”);
}

Section sec2 = new Section(pdf1);
pdf1.getSections().add(sec2);

sec2.getParagraphs().add(new Text(sec2, “Section 2”));

pdf1.save(new FileOutputStream(“D:\test.pdf”));

for (int i = 0; i < pdf1.getSections().size(); i++) {
Section s = pdf1.getSections().getAt(i);
System.out.println(s.getStartingPageNumber());
}

This prints two times “1”, but second section starts at page 7.

Also Pdf.version() from version 2.4.3 you provided returns “Aspose Pdf Java 2.4.0.0”. Is this ok?



And I have one more question. How can i set columns span in version 2.4. When I use method cell.setColumnSpan(2) I get exception
"com.aspose.pdf.exception.AsposeBaseException: null
at com.aspose.pdf.elements.Section.a(Unknown Source)
at com.aspose.pdf.elements.Pdf.if(Unknown Source)
at com.aspose.pdf.elements.Pdf.a(Unknown Source)
at com.aspose.pdf.elements.Pdf.save(Unknown Source)


Thank You for your time.
Regards,
Maciek

Hello Maciek,

I've tested the scenario and I'm able to notice that Section.getStartingPageNumber() is returning incorrect page number information. I'm afraid we might not be able to correct this issue in older version of Aspose.Pdf for Java but we will try our level best to get it resolved in our new versions.

Regarding Col.setColumnSpan(...) issue, please try using the attached Aspose.Pdf for Java 2.4.3.1. As per my observation, setColumnSpan is working correctly in this version.

When using Pdf.version(..) method with this version, its returning the correct value.

In case you still face any problem or you've any further query, please feel free to contact.

We apologize for your inconvenience.

Hello,
Thanks for the fix. In this version setColumnSpan() works fine but the sign $p is not replaced with current page number.

Section.FirstPageNumber works fine in version 2.5.0 so I really hope that you will soon fix bugs with creating images from memory so we could start using it. It seems to me that this is a basic functionality so i hope you’ve put high priority to fix this bugs.

Hello Maciek,

The issue regarding $p is a regression bug in Aspose.Pdf for Java 2.4.3.1 and it was earlier resolved in 2.4.2.13. Can you please try using the attached version of Aspose.Pdf for Java and in case you still face any further problem, please feel free to contact.

We will try our level best to get the issue regarding creation of images using Memory stream to be resolved, ASAP. Once we've some updates regarding its resolution, we would be pleased to update you with the status of correction.

We're really sorry for your inconvenience.

Hello Maciek,

Thanks for your patience.

I am pleased to inform you that PDFJAVA-14913 is resolved in our Aspose.Pdf for Java 2.7.0 release version. I have tested the following code snippet with this version and the PDF document is properly being generated. Please try using Aspose.Pdf for Java 2.7.0 (which can be downloaded from here) and see if it can resolve your problem.

[Java]

Pdf pdf1 = new Pdf();
Section sec1 = pdf1.getSections().add();
aspose.pdf.Image image3 = new aspose.pdf.Image(sec1);
sec1.getParagraphs().add(image3);

image3.getImageInfo().setFile("http://images.google.com.pk/intl/en_ALL/images/logos/images_logo_lg.gif");
image3.getImageInfo().setImageFileType(ImageFileType.Gif);
image3.getImageInfo().setOpenType(ImageOpenType.Url);
image3.getImageInfo().setTitle("jpeg image with url");
image3.setImageWidth(154);
image3.setImageHeight(112);

pdf1.save("D:/pdftest/Imagetemplate_Testimage.pdf");

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


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