Create a ‘Document’ from an existing ‘helloWorld.doc’ file (which contains multiple images).
Generate html by saving the file as ‘helloWorld.html’
Read the ‘helloWorld.html’ file and put the content into TinyMCE editor
User edits at this point the document using TinyMCE editor
Finally we create a new instance of Document and we insert the final html text and save it as “final.doc”
Issue:
Even tho the html still contains the images, the “final.doc” does not show the images and it shows a red ‘X’ image instead.
Question:
Starting from the HTML text (edited by the user) and considering that we still have the original images (saved to disk by aspose in step 2), is there a way to readd those images to the document so we see the images instead of the red ‘X’.
You can try exporting images in ‘helloWorld.doc’ as Base64 strings in ‘helloWorld.html’ and then pass HTML (with embedded images) to TinyMCE editor.
Document doc = new Document("E:\\Temp\\helloWorld.doc");
HtmlSaveOptions htmlSaveOptions = new HtmlSaveOptions(SaveFormat.HTML);
htmlSaveOptions.setExportImagesAsBase64(true);
doc.save("E:\\Temp\\helloWorld.html", htmlSaveOptions);
In case the above code does not work or is not acceptable in your scenario, then please ZIP and attach the following resources here for testing:
Your simplified source document (helloWorld.doc)
Aspose.Words for Java 20.6 generated output HTML file that you are passing to TinyMCE editor (helloWorld.html)
Piece of source code you used to generate above HTML
The ‘final html’ string returned by TinyMCE editor
Piece of 'source code you are using to generate ‘final.doc’ from final html
The final.doc showing the undesired behavior
Any other necessary resources required to reproduce the issue on our end.
As soon as you get these pieces of information ready, we will start further investigation into your scenario and provide you more information. Thanks for your cooperation.
Thanks for such a quick response. We have tried this solution and, although we have to do more testing, first impression is that it could work! Thanks very much!