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

Free Support Forum - aspose.com

How can we merge two Aspose documents and make one?

private Document MergeDocuments(Document Doc1, Document Doc2)

{

Document docMerged = null;

//Need help here

return docMerged;

}

Hi<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Thanks for your inquiry. You can use Document.AppendDocument method to append one document to another.

http://www.aspose.com/documentation/file-format-components/aspose.words-for-.net-and-java/aspose.words.document.appenddocument.html

Also see the following article.

http://www.aspose.com/documentation/file-format-components/aspose.words-for-.net-and-java/append-one-document-to-another.html

Hope this helps.

Best regards.

Hi,

I have a related problem I was hoping I could get some help with. I'm using Words in ASP.NET environment. I have 2 documents, target and source. Both documents are created using MailMerge.Execute(). The source document is essentially a footer. The source document is appended to the target document using the routine, InsertDocument.

The problem I'm having is that sometimes the source document partially displays at the end of page 1 and to the beginning of page 2. Is there a way that I can make it display on page 1 only if the entire contents fits within page 1, otherwise, it should be displayed in it's entirety on page 2?

Thanks so much

Hi<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Thanks for your inquiry. Unfortunately there is no way to detect when pages starts and ends. Aspose.Words document represents content and formatting of a document, not its layout into lines and pages. So you can’t determine whether content is placed on first page of on the second one.

Best regards.

How about adding support for this? I've seen this mentioned in numerous posts. You could call it something like, "Document Footer" (as opposed to a page footer). A number of your clients have asked for this and could use it in their document generation applications that requires a document summary such as a grand total, signature line, etc. Words should be smart enough to append to the last page of the document if there was adequate room for it. Otherwise, it would be generated on a new page.

From the client's end it could be something as simple as a new SectionStart enumeration value.

Hi<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Thanks for your inquiry. We currently work on rendering engine. Hopefully this feature will be supported somewhere within few months. Unfortunately I can’t provide you exact date.

Best regards.

So for now, I will require the user to check a checkBox when the the application should create the footer it's entirety in a new page rather than trying to append to the previous page since it will not fit.

In trying to have the source document (footer) appear in it's entirety on the second page, I've tried playing with setting the document.LastSection.PageSetup.SectionStart = SectionStart.NewPage for both the source and target document. Neither worked - can you help me out please?

Note the target doc contains a header and a footer. I've attached my code.

Thank You.

Hi<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Thank you for additional information.

1. You should apply license before creating Aspose.Words.Document. in your code you set license after creating “headerTemplate” document.

2. You are using InsertDocument method. This method ignores all sections properties including headers and footers. So I think you should use AppentDocument method.

Hope this helps.

Best regards.

Thank you for your reply.

I've moved the apply license call as suggested.

When I use the AppendDoc method (as currently coded) rather than the InsertDocument method, the footer is generated on a new page by itself as required, however, the header and footer from the target document is not displayed on this new page.

Hi<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Thanks for your request. I think you should link header to previous section. For example see the following code:

//Open first document (with header)

Document dst = new Document(@"Test207\dst.doc");

//Open second document (with footer)

Document src = new Document(@"Test207\src.doc");

//Set link to previouse

src.FirstSection.HeadersFooters.LinkToPrevious(HeaderFooterType.HeaderPrimary, true);

//Merge documents

dst.AppendDocument(src, ImportFormatMode.KeepSourceFormatting);

//Save output document

dst.Save(@"Test207\out.doc");

Hope this could help you.

Best regards.

Hi,

Thanks for the response. I got it working - sort of, but I ran into other problems.

Would I be able to add the src doc as another footer to the last page of the document only? I say another because on every page there is already a "Page x of n" footer. I'd like to have the src doc as a footer that appears at the end of the last page only, just above the "Page x of n" footer.

One other question, when I use the Document.Save method to send the document to the client browser, my aspx page is not being repainted. Any clues? I don't have any Reponse.End statments in my code.

Thanks

Hi<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Thanks for your request. If I understood you correctly the last page should have footer that consists of footer of main document and footer of src document. If so you can just merge footers (just clone all nodes inside main document footer and append these nodes to src document footer.)

Best regards.