I need to convert docx file to an image page by page. So if I Pass page number to a method - that method should read that page out of docx file and convert that to an image. Any example of that using Apache POI API ? I did that for pptx file but was not able to find similar methods for docx. Following is the code for pptx.
FileInputStream is = new FileInputStream(strTempPath);
XMLSlideShow pptx = new XMLSlideShow(is);
is.close();
double zoom = 2; // magnify it by 2
AffineTransform at = new AffineTransform();
at.setToScale(zoom, zoom);
Dimension pgsize = pptx.getPageSize();
XSLFSlide[] slide = pptx.getSlides();
}
// BufferedImage img = new BufferedImage((int)Math.ceil(pgsize.width*zoom), (int)Math.ceil(pgsize.height*zoom), BufferedImage.TYPE_INT_RGB);
BufferedImage img = new BufferedImage(pgsize.width, pgsize.height, BufferedImage.TYPE_INT_RGB);
Graphics2D graphics = img.createGraphics();
//graphics.setTransform(at);
graphics.setPaint(Color.white);
graphics.fill(new Rectangle2D.Float(0, 0, pgsize.width, pgsize.height));
slide[iPageNo].draw(graphics);
// FileOutputStream output = new ByteArrayOutputStream("C:/Temp/aspose/word/slide-" + (10 + 1) + ".png");
output = new ByteArrayOutputStream();
javax.imageio.ImageIO.write(img, "png", output);