Hello team,
I would like to add text at the beginning of document with left alignment, but when I add it it affects the document’s text too.
My code is:
Document doc = new Document(@"C:\...\NewFolder\sample.docx");
DocumentBuilder builder = new DocumentBuilder(doc);
builder.MoveToDocumentStart();
Font font = builder.Font;
font.Size = 12;
font.Bold = false;
font.Name = "Calibri";
ParagraphFormat paragraphFormat = builder.ParagraphFormat;
paragraphFormat.Alignment = ParagraphAlignment.Left;
paragraphFormat.KeepTogether = false;
paragraphFormat.KeepWithNext = false;
builder.InsertParagraph();
builder.Write("Sample Text");
builder.InsertBreak(BreakType.LineBreak);
doc.Save(@"C:\...\NewFolder\out.docx");
The input document is:
sample.docx (15.7 KB)