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

Free Support Forum - aspose.com

Combine or Merge Word documents into One using C# .NET | Preserve Styles & Copy New Styles

Hi Team

We are facing issue while appending one document after other. Actually our requirement is to keep both document formatting as is and append one document after other without changing any style or formatting of any of the document.

Current method
destinationDoc.AppendDocument(sourceDoc, AW.ImportFormatMode.UseDestinationStyles);

which we are using is forcing us to keep either source or destination style. if we choose KeepDifferentStyles option still it impose formatting changes.

public enum ImportFormatMode
{
UseDestinationStyles = 0,
KeepSourceFormatting = 1,
KeepDifferentStyles = 2
}

Do we have method where it keeps both the document formatting separate and lets use it. please lets know if we need to provide more inputs and a prioritization will help us in resolving our issues quickly? Also lets know if you need specific document to research further, though it may be bit difficult as it has lots of client data.

@aspose.support,

To ensure a timely and accurate response, please ZIP and attach the following resources here for testing:

  • Your simplified input Word documents
  • Aspose.Words for .NET 20.6 generated output file showing the undesired behavior
  • Your expected file showing the desired output. You can create this document by using MS Word.
  • A comparison screenshot highlighting the problematic areas in this Aspose.Words 20.6 generated document (with respect to your expected file)
  • Please also create a standalone simple Console application (source code without compilation errors) that helps us to reproduce your current problem on our end and attach it here for testing. Please do not include Aspose.Words DLL files in it to reduce the file size

As soon as you get these pieces of information ready, we will start investigation into your particular scenario and provide you more information. Thanks for your cooperation.

P.S: It is safe to attach files in the forum. If you attach your documents/resources here, only you and Aspose staff members can view/download them. You can also remove any sensitive information from documents by replacing it with dummy data instead.

We are working on getting this file mean time can you please check if you have some required method which was mentioned in original request?

@aspose.support,

If you intend to save final (merged) document to PDF format, then we can offer you following workaround:

  1. Save all individual Word documents to PDF files by using Aspose.Words for .NET
  2. Use Aspose.PDF for .NET API to concatenate multiple PDF files into single PDF. Aspose.PDF can also convert this PDF document back to DOC or DOCX format.

However, if you want to save final (combined/appended) document to Word formats such as DOCX, DOC, RTF by using Aspose.Words alone, then I am afraid, the simplest way is to use Document.AppendDocument Methods. It accepts an ImportFormatMode enumeration parameter which defines how conflicting styles are handled when one document is imported into the other. As shown in following screenshot, when you try to copy content of one Word document inside another document, MS Word will also present you different Paste options.

hi

Thanks for your response, meantime we have created sample files and application to show you exact issue. please find attached sample application and dummy files.

dummy application will be sharing back in a day as it seems it size doesn’t allow me to upload it.

Thanks

KrishanCollatedFile.pdf (158.4 KB)
DOC1.zip (263.4 KB)

AsposeTestApp (1).zip (5.1 MB)

this is the sample app for above issue.

@aspose.support,

The “CollatedFile.pdf” was actually produced by using an old 19.12 version of Aspose.Words for .NET on your end. We suggest you to please upgrade to the latest 20.7 version and see how it goes on your end?

We have also produced a PDF file by running your code with 20.7 version on our end and attached it here for your reference. (see pdffile_1157397795.pdf (153.1 KB))

Do you see the same problem in above “pdffile_1157397795.pdf”? If yes, then please ZIP and attache the following resources for further testing:

  • Instead of PDF, save final document to DOCX format
  • Your expected file showing the desired output. You can create this document by using MS Word.
  • A comparison screenshot highlighting the problematic areas in above Aspose.Words 20.7 generated document (with respect to your expected file)

We will then start further investigation into your particular scenario and provide you more information.