What is the recommended strategy for in code to splice a set of MS Word documents together into one?
Cheers
Nik
-
Go look at the various SDKs available. This is much easier to do if you are using Word 2007, as the file is actually a zip file containing various XML documents. MS even has an SDK called "Open XML Format SDK 1.0" which provides strongly typed classes for working with the new office format.
niklassaers-vc : Thanks, but I cannot assume that only the current version of Word is being used, I need to support older versions as well, so I cannot go the DocX route. -
http://www.codeproject.com/KB/aspnet/AppendWordDocuments.aspx
Or any of these: http://www.google.com/search?hl=en&q=append+microsoft+word+documents
niklassaers-vc : Thanks, the codeproject.com project solved the problem, I'll use that as my template. :-) Great find. :-) -
If you are using Open XML (ie docx), there are 2 basic approaches to solving this problem:
The first is to do what is necessary so ids point to the correct relationship (eg for images, hyperlinks), and styles are defined etc. A good explanation of what you need to do can be found at http://blogs.msdn.com/ericwhite/archive/2009/02/05/move-insert-delete-paragraphs-in-word-processing-documents-using-the-open-xml-sdk.aspx
PowerTools implements that.
The second is to use altChunk: http://blogs.msdn.com/ericwhite/archive/2008/10/27/how-to-use-altchunk-for-document-assembly.aspx
-
Very easy to do with Aspose.Words.
It will properly combine styles, lists etc in the resulting document.
0 comments:
Post a Comment