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

Free Support Forum - aspose.com

Insert one document into another document

I would like to copy the content of one document into another document with Aspose.Words for Java.
For this reason I copied the example https://docs.aspose.com/words/java/insert-and-append-documents/ into my Java development environment (without any changes).
Unfortunately I got an error in the line where looping through all sections in the source document.

// Loop through all sections in the source document.
for (Section srcSection : srcDoc.getSections())

The error says: “type mismatch: cannot convert from element type Node to Section”
But the description of getSections() says that it returns a SectionCollection.
Is this maybe an implementation error that is fixed in a newer Aspose.words Release??
Thanks for your support.
(I’ve searched in the forum before I wrote this question. Couldn’t find something suitable).
Best regards,

This message was posted using Page2Forum from Document - Aspose.Words for .NET and Java

Thanks for your inquiry. The code works fine on my side. I use the latest version of Aspose.Words for java for testing.
Also I think you can solve the problem using the following code to loop though sections.

for(int sectIdx=0; sectIdx<srcDoc.getSections().getCount(); sectIdx++)
    Section srcSection = srcDoc.getSections().get(sectIdx);

Hope this helps.
Best regards.

thanks for your fast answer!
I’ve just downloaded the latest version of Aspose.Words for Java and with this the error disappeared!!
Best regards