Convert docx multiple pages to single png java

Hi Team,
we want to convert multiple pages in a docx document into single png file(in java). All the sample code shows page by page conversion to individual png files. could you please let us know if there is a straight forward way to do this please.
Tried with below code to convert all pages to single png, but it gives 1st page as png.

Document doc = new Document(inputfilepath);|
ImageSaveOptions imageSaveOptions = new ImageSaveOptions(SaveFormat.PNG);|
imageSaveOptions.setDmlRenderingMode(DmlRenderingMode.DRAWING_ML);|
imageSaveOptions.setPageSet(new PageSet(new PageRange(0,doc.getPageCount()-1) ));|
imageSaveOptions.setResolution(96);|
doc.save(outputFilePath, imageSaveOptions);|

Thanks for your help in advance.

You can achieve this using Document.renderToScale or Document.renderToSize methods. Please see the code examples provided in our documentation.

Thanks for your response.

1 Like