How to save images for all pages in document?

Hi ,


I am using aspose latest version for document conversion. I needed to create images for all pages in a document. Below is my code

Document doc = new Document(“input.doc”);
ImageSaveOptions options = new ImageSaveOptions(SaveFormat.PNG);
options.setPageCount(3);
doc.save(“output.png”, options);

In Aspose Api, it states that setPageCount sets the number of pages to render when saving … But what i got is a single image .

or should i try like this

Document doc = new Document(“input.doc”);
int pageCount = doc.getPageCount();
for(int i=0; i<pageCount;i++){
ImageSaveOptions options = new ImageSaveOptions(SaveFormat.PNG);
options.setResolution(300);
options.setPageIndex(i);
doc.save(“output_”+i+".png", options);
}

My requirement is to save images for all pages in document.


Thanks.

Hi Anbu,


Thanks for your inquiry. In order to save all pages in Microsoft Word document to separate Png image files, please see the following code snippet:

Document document = new Document(@“C:\test\In.docx”);

ImageSaveOptions options = new ImageSaveOptions(SaveFormat.Png);
options.PageCount = 1;

// Save each page of the document as Png.
for (int i = 0; i < document.PageCount; i++)
{
options.PageIndex = i;
document.Save(string.Format(@“C:\test\out_{0}.png”, i), options);
}

I hope, this will help

Best Regards,