We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Page Break Not being Rendered

Hello,

I am using Aspose.Words for .net to convert .docx to PDF. It is working very well and I am very satisfied with this product.

The issue is with the document.AppendDocument() method: it is not appending page breaks.

stDoc.AppendDocument(srcDoc, ImportFormatMode.KeepSourceFormatting)

I use Send a number of Docx Documents to be converted into individual PDFs, and combined into one PDF conatining all the documents.

However, When I use AppendDocument, I loose the page break in the merged PDF. It shows up in the single PDF though.

How can I preserve the page breaks during merge?

I’ve attached the a sample DOCX and PDF document.

Thanks,

Rafal

Hi Rafal,

Thanks for your inquiry. In case you are using an older version of Aspose.Words, I would suggest you please upgrade to the latest version (v13.3.0) from here and let us know how it goes on your side. If the problem still remains, please attach your input Word documents which you have used to merge/join documents here for testing. I will investigate the issue on my side and provide you more information.

Moreover, I have converted your shared Docx to Pdf and have not found any issue with output Pdf file. I have attached the output Pdf file with this post for your kind reference. Please let us know if you have any more queries.

Hi Tahir,

Thanks for your reply. The issue I’m having is not with an individual document.
The problem is when I merge multiple DOCX documents: when any of them have a page break which results in a blank page, the blank page is omitted from the merged Document and PDF.

This causes an issue because the page numbering is not adjusted in the table of contents, resulting in a skipped number.

So I need to know how to preserve blank pages in the merged document / PDF.

To see the issue, please merge the DOCX I’ve attached in the first post with itself and prepend a table of contents using Aspose.Words. You should see a page missing (the blank page) and the page numbering for the second / duplicated paper will be off by one.

Edit: The blank page occurs on page 22 of the DOCX. If you look at the journal that I’ve attached, you will see that the table of contents indicates that the next paper starts on page 31, but because the blank page is omitted, it starts on page 30.

This problem persists even after I upgraded to the latest version of Aspose Words.

Thanks,

Rafal

Hi Rafal,

Thanks for your inquiry. I have tested the scenario while using latest version of Aspose.Words for .NET 13.4.0 and have not found the shard issue. Please use the following code snippet with latest version of Aspose.Words and let us know how it goes on your side. I have attached the output Pdf/Docx with this post for your reference. Hope this helps you. Please let us know if you have any more queries.

// The document that the content will be appended to.
Document dstDoc = new Document(MyDir + "Merge.docx");
DocumentBuilder builder = new DocumentBuilder(dstDoc);
builder.InsertTableOfContents("\\o \"1-3\" \\h \\z \\u");
// The document to append.
Document srcDoc = new Document(MyDir + "Merge.docx");
srcDoc.FirstSection.PageSetup.SectionStart = SectionStart.NewPage;
srcDoc.FirstSection.PageSetup.RestartPageNumbering = false;
// Append the source document to the destination document.
// Pass format mode to retain the original formatting of the source document when importing it.
dstDoc.AppendDocument(srcDoc, ImportFormatMode.KeepSourceFormatting);
dstDoc.UpdateFields();
// Save the document.
dstDoc.Save(MyDir + "Out.docx");
dstDoc.Save(MyDir + "Out.pdf");