@Crane If the document is inserted into the last empty section (or in a newly created empty document), all imported sections are formatted as specified in the source document, i.e. page setup from the source document are applied to the target section.
If possible, could you please attach your destination and source documents along with current and expected output documents here for our reference? We will check them and provide you more information.
@Crane If you would like to keep the original documents’ page setup, I would suggest you to use Document.appendDocument method instead of DocumentBuilder.insertDocument method. In this case entire section are copied into the destination document and page setup are preserted:
Document doc1 = new Document("C:\\Temp\\insert.docx");
Document doc2 = new Document("C:\\Temp\\test.docx");
doc1.appendDocument(doc2, ImportFormatMode.KEEP_SOURCE_FORMATTING);
doc1.save("C:\\Temp\\out.docx");
Sets consent for sending user data to Google for online advertising purposes.
Sets consent for personalized advertising.
Cookie Notice
To provide you with the best experience, we use cookies for personalization, analytics, and ads. By using our site, you agree to our cookie policy.
More info
Enables storage, such as cookies, related to analytics.
Enables storage, such as cookies, related to advertising.
Sets consent for sending user data to Google for online advertising purposes.
Sets consent for personalized advertising.
Cookie Notice
To provide you with the best experience, we use cookies for personalization, analytics, and ads. By using our site, you agree to our cookie policy.
More info
Enables storage, such as cookies, related to analytics.
Enables storage, such as cookies, related to advertising.
Sets consent for sending user data to Google for online advertising purposes.