Hi jslots,
We have fixed your problem, please download the new hotfix of spire.doc v4.4.5 from http://www.e-iceblue.com/Download/download-word-for-net-now.html.
Sorry for the delay.
// first added some code to set licensekey. just not added to this post.
//new document and set PageSetup
Document document1 = new Document();
Section section1 = document1.AddSection();
section1.PageSetup.PageSize = PageSize.A3;
section1.PageSetup.Orientation = PageOrientation.Landscape;
InsertHeaderAndFooter(section1);
// add paragraph1
Paragraph paragraph1 = section1.AddParagraph();
paragraph1.Text = "Test1";
// add table and add content
Table table1 = section1.AddTable();
TableRow tableRow1 = table1.AddRow(2);
TextRange textRange1 = tableRow1.Cells[0].AddParagraph().AppendText("text");
tableRow1.Cells[0].Width = 100f;
textRange1.CharacterFormat.FontName = "comic sans ms";
//add image to 2nd column of table
TableCell tableCell1 = tableRow1.Cells[1];
tableCell1.Width = 500f;
Paragraph paragraph2 = tableCell1.AddParagraph();
paragraph2.AppendPicture(new Bitmap(@"c:\temp\\image1.jpg"));
//dummy code to add some pages
section1 = document1.AddSection();
section1.AddParagraph().AppendText("1");
section1 = document1.AddSection();
section1.AddParagraph().AppendText("2");
section1 = document1.AddSection();
section1.AddParagraph().AppendText("3");
// save
document1.SaveToFile(@"c:\temp\test.docx", FileFormat.Docx2010);
document1.SaveToFile(@"c:\temp\test.pdf", FileFormat.PDF);
}
private static void InsertHeaderAndFooter(Section section)
{
HeaderFooter header1 = section.HeadersFooters.Header;
HeaderFooter footer = section.HeadersFooters.Footer;
InsertHeader(header1);
//insert pagenumber in footer
Paragraph footerParagraphRight = footer.AddParagraph();
footerParagraphRight.AppendField("page number", FieldType.FieldPage);
footerParagraphRight.AppendText(" van ");
footerParagraphRight.AppendField("number of pages", FieldType.FieldNumPages);
footerParagraphRight.Format.HorizontalAlignment = HorizontalAlignment.Right;
}
private static void InsertHeader(HeaderFooter header)
{
//insert picture and text to header
Paragraph headerParagraph = header.AddParagraph();
//border
headerParagraph.Format.Borders.Bottom.BorderType = BorderStyle.Single;
//Fill header with text
TextRange text = headerParagraph.AppendText("Headertext");
text.CharacterFormat.FontName = "Arial";
text.CharacterFormat.FontSize = 14f;
text.CharacterFormat.Italic = true;
headerParagraph.Format.HorizontalAlignment = HorizontalAlignment.Left;
//header picture on right top of the page.
DocPicture headerPicture = headerParagraph.AppendPicture(new Bitmap(@"C:\temp\image1.jpg"));
headerPicture.TextWrappingStyle = TextWrappingStyle.InFrontOfText;
headerPicture.HorizontalOrigin = HorizontalOrigin.Margin;
headerPicture.HorizontalAlignment = ShapeHorizontalAlignment.Right;
headerPicture.VerticalOrigin = VerticalOrigin.Page;
headerPicture.VerticalAlignment = ShapeVerticalAlignment.Inside;
}
HeaderFooter footer = section.HeadersFooters.Footer;
Table t = footer.AddTable(false);
TableRow tr1 = t.AddRow(2);
TableRow tr2 = t.AddRow(2);
float f = (section.PageSetup.ClientWidth ) / 2;
tr1.Cells[0].Width = f;
tr1.Cells[1].Width = f;
tr2.Cells[0].Width = f;
tr2.Cells[1].Width = f;
tr2.RowFormat.Borders.Top.BorderType = BorderStyle.Single;
//insert datetime in footer
Paragraph footerParagraphLeft = tr2.Cells[0].AddParagraph();
footerParagraphLeft.Format.HorizontalAlignment = HorizontalAlignment.Left;
footerParagraphLeft.AppendText(DateTime.Now.ToString("dd-MM-yyyy HH:mm:ss"));
//insert pagenumber in footer
Paragraph footerParagraphRight = tr2.Cells[1].AddParagraph();
FooterParagraphRight.AppendField("page number", FieldType.FieldPage);
footerParagraphRight.AppendText(" of ");
footerParagraphRight.AppendField("number of pages", FieldType.FieldNumPages);
footerParagraphRight.Format.HorizontalAlignment = HorizontalAlignment.Right;