In cells package we have an API which takes graphics object.
SheetRender.toImage(g2d)
Is there a similar api in words ?
In cells package we have an API which takes graphics object.
SheetRender.toImage(g2d)
Is there a similar api in words ?
@sushma1509 I am afraid there is no API to render any node in the document to image. There is something similar for shapes and office math equations:
https://reference.aspose.com/words/java/com.aspose.words/shapebase/#getShapeRenderer
https://reference.aspose.com/words/java/com.aspose.words/officemath/#getMathRenderer
If you need to render some node to image, you can copy the node into a separate document and render the whole document. Could you please let us know what object you would like to render to image?
@sushma1509 PageInfo
is not a node in the document. It is a class that contains information about the page. Do you need to save a particular page to image?
@alexey.noskov
Yes. I get the input stream, I have converted the same to a document.
Now I want to create a image object for each page in the document.
Basically write each page onto a graphics object or a java.awt.Image object
@sushma1509 You can achieve this using the following simple code:
Document doc = new Document("C:\\Temp\\in.docx");
ImageSaveOptions opt = new ImageSaveOptions(SaveFormat.PNG);
for (int i = 0; i < doc.getPageCount(); i++)
{
opt.setPageSet(new PageSet(i));
doc.save("C:\\Temp\\page_" + i + ".png", opt);
}
Please see our documentation to learn more about conversion document to image:
https://docs.aspose.com/words/java/convert-a-document-to-an-image/
I do not want to create a document back. I just want a image object.
Something like,
PageInfo page = document.getPageInfo(pageNum)
page.toImage(g2d)
SheetRender in cells has this. I am looking for something similar.
My requirement is not to create an output document in the form of png or jpeg but instead create an image object
Again this will be for an entire document right ? This is not per page I suppose.
doc.renderToSize ()