I'm trying to use style from a Document for another Document.
I use Spire Doc for Java (12.1.0) on Windows environnement.
On one of my Document (htmlStyle.docx), I have style like "Heading 1" color in blue and with font Calibri 18 no bold (for exemple).
I use this file as Source Style.
I have another Document with content, it's a html file with default Style.
Im trying to replace styles from html file by these ones in Source Style.
My code look pretty simple but the main function to clone Style not work. (cloneDefaultStyleTo / cloneThemesTo)
You can check result.docx file.
- Code: Select all
//Create object of Document class
Document html = new Document(is, FileFormat.Html);
Document styleDocx = new Document(style, FileFormat.Docx);
// Copy default style to another document
styleDocx.cloneDefaultStyleTo(html);
//styleDocx.cloneThemesTo(html);
// Saving to tmp file outputstream
html.saveToStream(os, FileFormat.Docx);
I also tried to merge the document while keeping the styles but they are not copied at hundred percent, the color is taken but not the font size and other properties.
My last try was browse Section and Paragraph to get a list of Style and add to the main html Document but without success.
Do you already encountered this problem?