Inserting .odt doc into another doc behaves differently than with .doc

inserting .odt doc into another doc places document on new page - when inserting a .doc , it inserts directly after the content on the source page- i am using the insertDocument routine provided on the support forum. please help

Hello
Thanks for your request. Maybe you should just specify section start Continuous for source document. See the following snippet of code:

srcDoc.Sections[0].PageSetup.SectionStart = SectionStart.Continuous;

You should specify this just before appending section to the main document.
Hope this helps.
Best regards,

Hi
Thanks for your request. Could you please attach your sample documents here for testing? We will check them and provide you more information.
Best regards,

Hi - I tried your suggestion - it did not work unfortunately.
Following is the code. Note that this works perfectly with .doc and .docx files. Not with .odt however.
Thanks

public class test {
    public static void main(String[] args) {
        try {
            // 1. create a new doc , add a table and save in .pdf and .odt and
            // .docx
            Document doc = new Document();
            DocumentBuilder builder = new DocumentBuilder(doc);
            // builder.writeln("Generated with Aspose.Words");
            insertTable(builder, "BUS_DESCRIPTION");
            builder.writeln();
            insertTable(builder, "LIMITS");
            builder.writeln();
            // builder.moveToDocumentEnd();
            // builder.
            Node curNode = builder.getCurrentParagraph();
            // Node curNode = builder.getCurrentNode();
            // String formName = "ADF3002_0110";
            String formName = "ACT0001_0611";
            String fileName = "c://TEMP//" + formName;
            String inFile = fileName + ".odt";
            Document srcDoc = new Document(inFile);
            // srcDoc.Sections[0].PageSetup.SectionStart =
            // SectionStart.Continuous;
            //srcDoc.getSections().get(0).getPageSetup().setSectionStart(SectionStart.CONTINUOUS);
            insertDocument(curNode, srcDoc);
            builder.getPageSetup().setRightMargin(ConvertUtil.inchToPoint(0.75));
            builder.getPageSetup().setLeftMargin(ConvertUtil.inchToPoint(0.75));
            insertFooter(builder, formName);
            // insert watermark text
            insertWatermarkText(doc, "WaterMark");
            doc.save(fileName + "_PROC" + ".pdf");
            doc.save(fileName + "_PROC" + ".docx");
            // dst.save(fileName + "_PROC2" + ".pdf");
            // getFiles();
        } catch (Exception e) {
            System.err.println(e.getMessage());
            System.err.println(e.getStackTrace());
        }
    }

    public static void insertDocument(Node insertAfterNode, Document srcDoc) throws Exception {
        // Make sure that the node is either a paragraph or table.
        if ((insertAfterNode.getNodeType() != NodeType.PARAGRAPH) &
                (insertAfterNode.getNodeType() != NodeType.TABLE))
            throw new IllegalArgumentException(
                    "The destination node should be either a paragraph or table.");
        // We will be inserting into the parent of the destination paragraph.
        CompositeNode dstStory = insertAfterNode.getParentNode();
        // This object will be translating styles and lists during the import.
        NodeImporter importer = new NodeImporter(srcDoc, insertAfterNode.getDocument(),
                ImportFormatMode.KEEP_SOURCE_FORMATTING);
        // ImportFormatMode.USE_DESTINATION_STYLES);
        // ImportFormatMode.KEEP_SOURCE_FORMATTING);
        // Loop through all sections in the source document.
        for (Section srcSection : srcDoc.getSections()) {
            // Loop through all block level nodes (paragraphs and tables) in the
            // body of the section.
            for (Node srcNode : (Iterable) srcSection.getBody()) {
                // Let's skip the node if it is a last empty paragraph in a
                // section.
                if (srcNode.getNodeType() == (NodeType.BOOKMARK_START)) {
                    System.out.println("Bookmark found");
                }
                if (srcNode.getNodeType() == (NodeType.PARAGRAPH)) {
                    Paragraph para = (Paragraph) srcNode;
                    //
                    if (para.isEndOfSection() && !para.hasChildNodes())
                        continue;
                    //
                }
                // This creates a clone of the node, suitable for insertion into
                // the destination document.
                Node newNode = importer.importNode(srcNode, true);
                // Insert new node after the reference node.
                dstStory.insertAfter(newNode, insertAfterNode);
                insertAfterNode = newNode;
            }
        }
    }
}

Hello
Thank you for additional information. Also this problem might occur because PageBreakBefore property of the first Paragraph of the source document is set. Could you please check this?
If it does not help, could you please attached the documents you having problem with here for testing. I will check them on my side and provide you more information.
Best regards,

Thanks for your reply. I tried setting the pagebreakbefore to false and it still doesn’t work. I’ve attached the .java file and the .odt file.

Hello
Thank you for additional information. As I mentioned earlier the reason of the problem is PageBreakBefore option of the first paragraph of the source document. Please try using the following code to achieve what you need:

// String formName = "ADF3002_0110";
String formName = "ACT0001_0611";
String fileName = "c://TEMP//" + formName;
String inFile = fileName + ".odt";
Document srcDoc = new Document(inFile);
srcDoc.getFirstSection().getBody().getFirstParagraph().getParagraphFormat().setPageBreakBefore(false);
// srcDoc.Sections[0].PageSetup.SectionStart =
// SectionStart.Continuous;
// srcDoc.getSections().get(0).getPageSetup().setSectionStart(SectionStart.CONTINUOUS);
insertDocument(curNode, srcDoc);

Best regards,

I tried this before and it didn’t resolve the issue. Attached is the resultant file. Notice how the document is appended on a new page instead of after the table.

Hi
Thank you for additional information. I cannot reproduce the problem on my side using the latest version of Aspose.Words and your code with my changes:

srcDoc.getFirstSection().getBody().getFirstParagraph().getParagraphFormat().setPageBreakBefore(false);

I have sent the documents produced on my side to your e-mail.
Also, as I can see you are using Aspose.Words in evaluation mode. It can be the reason of the problem. Please request a 30-day Temporary License to test Aspose.Words without evaluation limitations as described here:
https://purchase.aspose.com/temporary-license
Best regards,