Free Support Forum - aspose.com

DOC Page to JPEG Image conversion problem with Aspose.Words for Java 10.3.0

Hi,


Let me first clear my requirement. I want to convert particular page from document to JPEG Image. Lets say if document contains total 15 page. And I want to convert only 9th page to JPEG Image.

I am facing some problem while getting it. I’ve used below code for the same as per given in DOCS. I am using the latest Aspose Words (Aspose.Words for Java 10.3.0).

Document doc = new Document(“Sample.doc”);
ImageSaveOptions options = new ImageSaveOptions(SaveFormat.JPEG);
options.setJpegQuality(100);
options.setPageIndex(8); // as index is starting from 0
options.setPageCount(1);
doc.save(“image.jpeg”, options);

Above code generates image but image is totally blank.
I’ve attached both input and output image file.

Am I doing anything wrong ? Any idea ?

Hi

Thanks for your request. As I can see your document contains only one page. So your code should look like this:

Document doc = new Document("C:\\Temp\\Sample.doc");

ImageSaveOptions options = new ImageSaveOptions(SaveFormat.JPEG);

options.setJpegQuality(100);

options.setPageIndex(0); // as index is starting from 0

options.setPageCount(1);

doc.save("C:\\Temp\\image.jpeg", options);

This code works fine on my side and the image is properly generated.

Best regards,

Hi Alexey,

Thanks for your reply. I’ve tried your suggested code with the same document. But still I am getting blank image. And also get below error.

java.lang.NullPointerException
at asposewobfuscated.hc.a(GdiRenderer.java:157)
at asposewobfuscated.s.a(ApsGlyphs.java:48)
at asposewobfuscated.p.a(ApsCompositeNode.java:22)
at asposewobfuscated.m.a(ApsCanvas.java:18)
at asposewobfuscated.p.a(ApsCompositeNode.java:22)
at asposewobfuscated.m.a(ApsCanvas.java:18)
at asposewobfuscated.p.a(ApsCompositeNode.java:22)
at asposewobfuscated.m.a(ApsCanvas.java:18)
at asposewobfuscated.p.a(ApsCompositeNode.java:22)
at asposewobfuscated.z.a(ApsPage.java:75)
at asposewobfuscated.hc.a(GdiRenderer.java:45)
at com.aspose.words.apg.a(SaveToImageHelper.java:119)
at com.aspose.words.apg.a(SaveToImageHelper.java:84)
at com.aspose.words.apg.a(SaveToImageHelper.java:61)
at com.aspose.words.vc.G(ImagingWriter.java:40)
at com.aspose.words.vc.a(ImagingWriter.java:32)
at com.aspose.words.Document.a(Document.java:1320)
at com.aspose.words.Document.save(Document.java:713)
at com.test.AsposeTestClass.main(AsposeTestClass.java:23)

What could be the issue?

And what if I have document with 100 page and I want image of 34th page? What will be the value of pageIndex and pageCount?

Hi Tejas,

Thanks for your request. But unfortunately, I cannot reproduce the problem on my side. Could you please describe your environment? I will check again and let you know the result.

Zero-based indexes are used, so to get the 34th page, you should set 33rd index.

Best regards,

Hi there,

Thanks for your inquiry.

I managed to reproduce the issue on my side. I have linked your request to the appropriate issue. We will keep you informed of any developments.

Thanks,

Hi Adam,

Thanks for your confirmation for reproducing the issue. What is the exact problem behind this. As Alexy was not able to reproduce it and you are able to reproduce the same. Is it something related to environment?

What could be the approximate time to get this issue resolved?

Hi Tejas,

I did have a look at the source code around the area where the exception occurs but couldn't find anything that stood out as being a possible cause for the issue (or any environment-dependent calls).

The developer responsible will take a closer look into this and provide some further information. He will also provide an estimation on when the issue can be fixed. He should provide some feedback within the next couple of days.

Thanks,

Thanks for the reply and awaiting for the response from respective developer.

Hi Tejas,

I also happened to encounter this exception in the sample codes while I was updating the Java samples. Intriguingly, I saw that the error occured in the command line but not from within the IDE. The difference being that JDK 1.6 was being used from the command line while JDK 1.5 was being used in the IDE.

Therefore, if you are able to use the previous version of the JDK then this would be the work around for the time being. I have retested your document on my side and the above code works well when using JDK 1.5. The developer will hopefully have this one fixed before the next release.

I suppose in our previous tests you and I were both using 1.6 whereas Alexey was using 1.5 which is why he could not reproduce the issue.

Thanks,

Thanks for the reply.

So finally we got exact issue, JDK version. We are using JDK 1.6 globally so it would not be possible to switch to JDK 1.5. So I have only option of waiting until issue get resolved :).

Hi

I'm very interrested in this feature. But, as for Tejas, Java 1.5 is not an option :-) Can you provide an estimation on when this issue can be fixed?

By the way; did you test the entire package on Java 1.6?

Also, the known issue/limitation "Rendering of document pages to TIFF and EMF is not available." When in 2011, as announced, will rendering to TIFF be possible?

Kind regards, Carsten

Hi Carsten,

Thanks for your inquiry.

Hopefully this issue will be fixed before the next release, however I cannot guarantee this. We will inform you as soon as this is available.

Regarding testing, all other features of Aspose.Words are Java version independent.

The developer responsible for implementing rendering to TIFF, EMF is working on this issue right now as well. We cannot provide a solid estimation of when this will be ready at the current time though.

If you have any further queries, please feel free to ask.

Thanks,

Hi

Thanks for your request. We will try to resolve the problem before the next hotfix that comes out at the end of this month. You will be notified as soon as fix is available.

Yes, we test entire package on Java 1.6, but Java 1.5 is the main environment for testing.

By the way, you do not need to use Java 1.5, you should simply use Aspose.Words JAR for Java 1.5. You can use it in Java 1.6 environment.

Best regards,

Thanks Alexey,


I’ve tried the same by using Aspose.Words JAR for JAVA-1.5 as well. But still I am getting blank images.

Hi

Thank you for additional information. In this case, you have to wait for the fix of the original issue. We will keep you informed and let you know once it is resolved.

Best regards,

Hi,

On the first post, I could see the issue status is resolved. But in 10.4.0 fix issue list I am not able to find the same issue.

So is it included in 10.4.0 or will be covered in next release.


Hi there,


Thanks for your inquiry.

The fix for this issue will be included in the next release (10.5). This is due out in around 4-5 days time. We will inform you as soon as it’s released.

Thanks,

The issues you have found earlier (filed as WORDSJAVA-393) have been fixed in this .NET update and in this Java update.


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

An image file contain with a additional texts. The texts are automatically generated by Aspose so how do i remove the default text in tha image???

Text is “Evaluate only.Created with Aspose word,copy right2003-2011 aspose pty ltd”.How do i resolve it?