Recommended approach to convert Word document to Images

Hi,

I am looking at capability to convert Word document to Image. Below is the way I am trying to achieve it. Each page is then written into ZipStream. I am not sure if there is better optimal way to achieve this.

Document document = new Document(is);
int pageCount = document.getPageCount();
ImageSaveOptions imageSaveOptions = new ImageSaveOptions(SaveFormat.JPEG);
for (int i = 0; i < pageCount; i++)
{
    PageSet pageSet = new PageSet(i);
    imageSaveOptions.setPageSet(pageSet);
    ByteArrayOutputStream imageBoS = new ByteArrayOutputStream();
    document.save(imageBoS, imageSaveOptions);
}

Can you help here.

Best Regards,
Anit

@nairanit25 Your code is right and there is no other more optimal way to convert each page of the document to images.