I am creating a sample document using the code below.
public static void CreateDocumentFile(string file)
{
using (WordprocessingDocument package = WordprocessingDocument.Create(file, WordprocessingDocumentType.Document))
{
package.AddMainDocumentPart();
package.MainDocumentPart.Document =
new Document(
new Body(
new Paragraph(
new Run(
new Text("Hello World!")))));
package.MainDocumentPart.Document.Save();
}
Document is created at the desired location but when i open it, gives me an error ,
The file cannot be opened because there are some problem in the content and it is pointing that my document.xml file contains error on line:1 col:198
my document.xml contains
<pre lang="xml"><?xml version="1.0" encoding="utf-8"?><w:document xmlns:w="http://schemas.openxmlformats.org/wordprocessingml/2006/main"><w:body><a:p xmlns:a="http://schemas.openxmlformats.org/drawingml/2006/main"><a:r><a:t>Hello World!</a:t></a:r></a:p></w:body></w:document>