Free Support Forum - aspose.com

Aspose.words for android issues of multiple page documents

I want to view doc file of multiple pages.On integrating the document viewer part with temporary license and making few changes for multiple pages there is a slideshow of the png files and only the last page is being saved as png file in my device.


Also it is taking a lot of time to convert the document to images. Let me know if other than converting it to png can I use input stream to make the rendering process more efficient.
Please find the source code below.
Hi Tarun,

Thanks for your inquiry. We are working over your query and will get back to you soon.

Best regards,

Hi Tarun,


Please attach your input Word document your’re getting this problem with here for testing. Are you getting this problem with one particular document or every document (DOC/DOCX/RTF etc) you try to render cause the same issue?

Best regards,

Its happening for all the DOC documents. Below is the attachment of input document.

Hi Tarun,

The problem seems to be in the following part of convertDocument method.

System.out.println("**********************No. of pages is****************"+doc.getPageCount());

System.out.println("**********************Page No.****************"+pageIndex);

pngFileName = getConvertedFileName(uriFile);

String outputFileName = doc + String.format("{0}_{1}.png", "AsposeOut", pageIndex + 1);

// String outputFileName = String.format("{0}\\{1}_{2}.Jpeg", "C:\\Temp", "Test", pageIndex + 1);

options.setPageIndex(pageIndex);

System.out.println("**********************options.setPageIndex****************"+pageIndex);

doc.save(pngFileName, options);

System.out.println("**********************doc.save****************"+pageIndex+pngFileName);

As you can see there are two variables pngFileName and outputFileName. pngFileName remains the same for all images and outputFileName is changing based on the page index. You are passing pngFileName to save method and every new image overwrites the previous one and you see last page image only.

You should pass outputFileName variable to save method as it is different for each page and will save each image with different name instead of overwriting previous one.

Best Regards,

I tried using outputFileName to save the file but I was geeting the following error:


Hi Tarun,

We are updating the sample according to your requirement and will share with you soon.

Best Regards,

May I know how much time will it take?

Hi Tarun,

Please make the following changes to your original code (shared in your first post) and share your result.

1. Delete the for loop from convertDocument method or move your code outside it.

for (int pageIndex = 0; pageIndex < doc.getPageCount(); pageIndex++)

2. Page count should always be set to 1 e.g.

options.setPageCount(1);

3. Manually set page index e.g. set it to 0 and check the output image then set it to 1 and check the output image and so on.

options.setPageIndex(0);

Best Regards,