Skip to content

GropenD/MadMilkman.Docx

Repository files navigation

MadMilkman.Docx component's icon MadMilkman.Docx

MadMilkman.Docx is a .NET library which can enable you to create a new DOCX file by appending HTML and RTF content to the DOCX document's body, header and footer.

// Create new file.
DocxFile document = new DocxFile();

// Add body content.
document.Body.AppendFile("Body.html", ContentType.Html)
             .AppendFile("Body.rtf", ContentType.Rtf);

// Add header content.
document.Header.AppendFile("Header.html", ContentType.Html)
               .AppendText("<body><p>Sample header content!</p></body>", ContentType.Html);

// Add footer content.
document.Footer.AppendFile("Footer.rtf", ContentType.Rtf)
               .AppendText(@"{\rtf1\ansi\cf1 Sample footer content!}", ContentType.Rtf);

// Save file.
document.Save("Sample.docx");

Generated Sample.docx file:

Sample.docx document's screen-shot

Overview:

The component uses an alternative format import part mechanism which enables importing of external content, in an alternate format, directly into a DOCX file. In other words it achieves combining of multiple documents into a single Word document.

The component currently supports importing of only HTML and RTF content, however the following is a list of additional formats that are supported in importing functionality:

  • TXT
  • XHTML
  • MHTML
  • XML
  • DOCX
  • DOCM
  • DOTX
  • DOTM

Feedback & Support:

Feel free to contact me with any questions or issues regarding the MadMilkman.Docx component. Also if you require a support for any additional format(s) or you have some other suggestion for component's improvement, don't hesitate to ask!

Installation:

You can download the library from here or from NuGet.

Limitations

The alternative format import part technique does not convert the imported content from an alternative format into a WordprocessingML format but rather relies on the consuming application to merge the documents. However by DOCX specification consuming application is free to ignore the imported external content. In other words some DOCX processing applications (like Microsoft Word) are able to render the external content(s) while others (like OpenOffice Writer) will ignore them and render a blank document instead.

About

MadMilkman.Docx is a .NET component which enables creation of DOCX files from HTML and/or RTF content.

Resources

License

Stars

Watchers

Forks

Packages

No packages published