Hi,
Thanks for your inquiry. I am afraid, there is no direct way in Aspose.Words for Java that you can use to convert Run of text to Image. However, you can implement the following workflow to meet this requirement:
1) Find Run node(s) where the specified character exists e.g.
Run run = ((Paragraph)doc.getLastSection().getBody().getLastParagraph().getPreviousSibling()).getRuns().get(0);
2) Find dimensions of this character as follows:
AffineTransform affinetransform = new AffineTransform();
FontRenderContext frc = new FontRenderContext(affinetransform,true,true);
Font font = new Font(run.getFont().getName(), Font.PLAIN, 12);
int textwidth = (int)(font.getStringBounds(run.getText(), frc).getWidth());
int textheight = (int)(font.getStringBounds(run.getText(), frc).getHeight());
3) Build a Graphics object and draw this character
4) Save the Graphics object to a PNG image stream in memory
5) Move the cursor to the current Run object that you want to replace with Image:
DocumentBuilder builder = new DocumentBuilder(doc);
builder.moveTo(run);
6) Insert the temporary image from stream using:
builder.insertImage(baos.toByteArray());
7) Remove the old Run as we don’t want text representation (run.remove())
8) Save the Word file to Html
Hope, this helps.
Best regards,