Free Support Forum -

Issue with page-break-after: auto style in RTF when inserted to a Word document


I have an RTF file which is inserted to a DOCX document and the document is saved. In the RTF document we have some page break styling used as follows:


But when the RTF is inserted in the DOCX document, there is an exception about the page break:

java.lang.IllegalStateException: You cannot insert document with this content into this location.
at com.aspose.words.zz81.zzZ(Unknown Source)
at com.aspose.words.DocumentBuilder.insertDocument(Unknown Source)

I have tested this issue with the latest version of Aspose word (16.10.0). I have attached the sample RTF file to reproduce the issue on your side.

I have also attached the sample JAVA code to test the issue.

Prabhaker Kr.

Hi Prabhaker ,

Thanks for your inquiry. After an initial test with Aspose.Words 16.10.0, we were unable to reproduce this issue on our end (see attached Docx). We also tested with the following simplified code. Hope, this helps.

<pre style=“color: rgb(0, 0, 0); font-family: “Courier New”; font-size: 9pt;”>Document outputDoc = new Document();
Document sampleDoc = new Document(“D:\temp\Sample.rtf”);
DocumentBuilder tempDocBuilder = new DocumentBuilder(outputDoc);
tempDocBuilder.insertDocument(sampleDoc, ImportFormatMode.KEEP_SOURCE_FORMATTING);“D:\temp\16.10.0.docx”);

Best regards,