Document Merge at the same page

Hi, im trying to merge two documents in one. Im using AttachDocument, but the new document always go to the next page. I`ve tried everything in the forum, and when i try do a replace in Document.Range with \f, i get a NullReferenceException

This message was posted using Page2Forum from How-to: Join and Append Documents - Aspose.Words for Java

Hi Rodrigo,
Thanks for your inquiry.
Please make sure you are setting the document to appear on the same page by using the code like this:

src.getFirstSection().getPageSetup().setSectionStart(SectionStart.CONTINUOUS);

If this does not work than the problem may be that the joining sections have different page setups (e.g different page sizes). This means the sections can not be joined continiously. To fix this you can set the same page setting for the sections as shown in the code below.

src.getFirstSection().getPageSetup().setPageWidth(dst.getLastSection().getPageSetup().getPageWidth());
src.getFirstSection().getPageSetup().setPageHeight(dst.getLastSection().getPageSetup().getPageHeight());

Thanks,