KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I've to merge multiple DOCX files (created with DocX Package ) into one big file. I've managed to merge multiple files already but I fail to merge Headers and Footers (they differ between files, pages). I've tried both DocX package and MS Office COM Interop and it simply doesn't want to merge the headers / footers. They are skipped. Does anyone can provide solution that would work? Can be anything really (including conversion to PDF using PDFCreator COM, or Interop or DocX ). I've also tried PDFCreator Sample in C# and it converts nicely one document to PDF but I don't know how to provide multiple documents to it so it would create one big PDF. So if anyone can provide a good (free) way it will be appreciated. This is what i use: internal static class DocumentsMerging { private static object missing = Type.Missing; private static ApplicationClass wordApplication { get; set; } private static void addDocument(object path, Document doc, bool firstDocument) { object subDocPath = path; var subDoc = wordApplication.Documents.Open(ref subDocPath, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing); try { if (!firstDocument) { insertPageBreak(doc); } object docStart = doc.Content.End - 1; object docEnd = doc.Content.End; object start = subDoc.Content.Start; object end = subDoc.Content.End; Range rng = doc.Range(ref docStart, ref docEnd); rng.FormattedText = subDoc.Range(ref start, ref end); //if (!lastDocument) { //} } finally { subDoc
Tags (comma-separated)
Save Edits
Cancel