We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Word to image conversion

I am using aspose-words-15.10.0-jdk16.jar with a temporary licence.
The resulted file of the conversion from word doc to a jpg file contains only the first page of the word document. I thought the whole document will be converted. could you please clarify.

Hi Talal,

Thanks for your inquiry. You need to set license before creating Document object. Also, please learn about the limitations of Aspose.Words when using in evaluation mode. Hope, this helps.

Best regards,

Thanks Awais for replying.

Actually I did get the 30-day temporary license.

I just need to know how to convert the whole document ( 5 pages) to one jpg file.

Could you provide me with the code please.

Thanks again.

Hi Talal,

Thanks for your inquiry. Please use the following Java code to save all pages in Word document to a single big JPEG image file:

Document doc = new Document(getMyDir() + "input.docx");
List<BufferedImage> images = new ArrayList<BufferedImage>();

int bigImageWidth = 0;

int bigImageHeight = 0;

ImageSaveOptions options = new ImageSaveOptions(SaveFormat.JPEG);


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


    ByteArrayOutputStream imgStream = new ByteArrayOutputStream();
    doc.save(imgStream, options);

    ByteArrayInputStream imgInputStream = new ByteArrayInputStream(imgStream.toByteArray());
    BufferedImage read = ImageIO.read(imgInputStream);

    bigImageWidth = (bigImageWidth < read.getWidth()) ? read.getWidth() : bigImageWidth;
    bigImageHeight += read.getHeight();



BufferedImage finalImage = new BufferedImage(bigImageWidth, bigImageHeight, BufferedImage.TYPE_INT_RGB);

Graphics2D g2d = finalImage.createGraphics();

int x = 0;

int y = 0;

for (BufferedImage bufferedImage : images)

    g2d.drawImage(bufferedImage, null, x, y);

    y += bufferedImage.getHeight();


ImageIO.write(finalImage, "JPG", new File("D:\Temp\out.jpg"));

Hope, this helps.

Best regards,

Thank you so much. It did help