I have a RendererFilter (ServletFilter) in which i capture the ServletResponse Content bascically an HTML.
Opening this HTML in a word doc works fine.
The issues here is all the image URLs in the html are not rendered in the word doc if no internet, hence i want to embed these images while converting.
I tried basic HTML img syntax with base64 encoded value using data:URI schema, but word doesn't render these images.
Now i am trying to use docx4j to do this, i was successful adding an image at the end of the document using the example AddImage from the samples.
But,i have lots of images in the html which are referenced by URL, these images are not rendered in word document if no internet, When i use AlternativeFormatInputPart entire html is converted to one big binary data, i can't use this xml to parse using an xxpath query, i am not sure what is the best way of doing this
Here is the code below using AlternativeFormatInputPart
- Code: Select all
AlternativeFormatInputPart afiPart = new AlternativeFormatInputPart(new PartName("/organize.html") );
//(content4.getBytes() is the content from servletReponse (HTML)
afiPart.setBinaryData(content4.getBytes());
afiPart.setContentType(new ContentType("text/html"));
Relationship altChunkRel = wordMLPackage.getMainDocumentPart().addTargetPart(afiPart);
// .. the bit in document body
CTAltChunk ac = Context.getWmlObjectFactory().createCTAltChunk();
ac.setId(altChunkRel.getId() );
wordMLPackage.getMainDocumentPart().addObject(ac);
Now with the above code, i have to replace a special text with an image.
Please help....
Any help/solution is highly appreciated.
-S