I am new in OpenXML. I am trying to create the word(.docx) file having simple text and images in it using openxml. I have already mentioned all this in my earlier post:
I am using this code
WordprocessingDocument doc = WordprocessingDocument.Create("E:\\test11.docx", DocumentFormat.OpenXml.WordprocessingDocumentType.Document);
{
MainDocumentPart mainPart = doc.AddMainDocumentPart();
mainPart.Document = new Document();
Body body = mainPart.Document.AppendChild(new Body());
Paragraph para = body.AppendChild(new Paragraph());
ParagraphProperties oParagraphProperties = para.AppendChild(new ParagraphProperties());
Run run = para.AppendChild(new Run());
Text tt = new Text(str);
run.AppendChild(tt);
RunProperties runProp = new RunProperties(); // Create run properties.
RunFonts runFont = new RunFonts() { Ascii = "Cambria(Headings)", HighAnsi = "Cambria(Headings)" };
Bold bold = new Bold();
DocumentFormat.OpenXml.Wordprocessing.Color Color1 = new DocumentFormat.OpenXml.Wordprocessing.Color() { Val = "0EBFE9" };
Italic ita = new Italic();
runProp.Append(bold);
runProp.Append(Color1);
runProp.Append(ita);
FontSize size = new FontSize();
size.Val = new StringValue((fontSize * 2).ToString()); // 48 half-point font size
runProp.Append(runFont);
runProp.Append(size);
run.PrependChild<RunProperties>(runProp);
}
That works fine for creating simple .docx file but i am having some coordinates and width height issues in text boxes. You can have a look on attached screenshots for understanding properly the issue.
Original File
I want to create a file having text on same position like Original file. Thanks.
Issues like writing the correct C# code that will produce a certain Open XML document can be solved easily using a sample document and the Document Reflector that comes with the Open XML SDK:
OpenXmlSdkTool.exe
) located inC:\Program Files (x86)\Open XML SDK\V2.5\tool
(when installed to the default location).