Hi,
I have a word document and I want to add to the end of this document a table with 2 columns: first column will contain an auto incremented number and the second column the name of a related document. My problem is that if I save the document as word (.doc) the document looks ok, but when I save the document as pdf the second column of this table is removed.
Here is the code:
Document doc = new Document("Main.doc");
DocumentBuilder builder = new DocumentBuilder(doc);
builder.MoveToDocumentEnd();
builder.InsertBreak(BreakType.LineBreak);
builder.InsertBreak(BreakType.LineBreak);
// Set font properties for header text.
builder.Font.Name = "Arial";
builder.Font.Bold = true;
builder.Font.Size = 12;
builder.Write("Attachments");
builder.StartTable();
builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;
builder.ParagraphFormat.StyleIdentifier = StyleIdentifier.Normal;
builder.Font.Size = 10;
double tableWidth = builder.CurrentSection.PageSetup.PageWidth - builder.CurrentSection.PageSetup.LeftMargin - builder.CurrentSection.PageSetup.RightMargin;
builder.RowFormat.Height = ConvertUtil.MillimeterToPoint((float) 3.6);
builder.RowFormat.HeightRule = HeightRule.Exactly;
builder.CellFormat.Borders.Color = Color.Black;
builder.CellFormat.Shading.BackgroundPatternColor = Color.FromArgb(230, 230, 230);
builder.CellFormat.Borders.LineStyle = LineStyle.Single;
builder.InsertCell();
builder.CellFormat.Width = tableWidth / 3;
builder.Write("No");
builder.InsertCell();
builder.CellFormat.Width = tableWidth * 2 / 3;
builder.Write("Attached Document");
builder.EndRow();
builder.Font.Bold = false;
builder.CellFormat.Shading.BackgroundPatternColor = Color.Transparent;
int index = 1;
foreach(string item in Attachments)
{
builder.InsertCell();
builder.CellFormat.Width = tableWidth / 3;
builder.Write(string.Format("{0:N0}", index));
builder.InsertCell();
builder.CellFormat.Width = tableWidth * 2 / 3;
builder.Write(item);
builder.EndRow();
index++;
}
builder.EndTable();
doc.Save("Result.pdf");
// doc.Save("Result.doc");
I attached the base document: Main.doc and the resulting files: Result.doc and Result.pdf.
Thanks in advance for any help.