I’m using following code to generate new document using two separate document.
public class StyleIssueInTheDocument
{
public static void main(String[] args) throws Exception
{
String basePath = "/home/nobilex/Downloads/";
Document baseDoc = new Document(basePath + "baseDoc.docx");
Document workingDoc = new Document(basePath + "Working.docx");
Document notWorkingDoc = new Document(basePath + "NotWorking.docx");
generateDoc(baseDoc, workingDoc, basePath + "expected.docx");
generateDoc(baseDoc, notWorkingDoc, basePath + "not-expected.docx");
}
private static void generateDoc(Document baseDoc, Document destDoc, String finalDocName) throws Exception
{
baseDoc.copyStylesFromTemplate(destDoc);
DocumentBuilder documentBuilder = new DocumentBuilder(destDoc);
documentBuilder.insertDocument(baseDoc, ImportFormatMode.USE_DESTINATION_STYLES);
documentBuilder.getDocument().save(finalDocName);
}
}
files.zip (78.0 KB)
In the above code Working.docx and NotWorking.docx both files are equals but generating different results.
Let me know what are the changes requires in the NotWorking.docx to generate the expected result.