/// <summary> /// Defines page setup, headers, and footers. /// </summary> private void DefineContentSection(Document document, String textHeader, String textFooter) { Section section = document.AddSection(); section.PageSetup.OddAndEvenPagesHeaderFooter = true; section.PageSetup.StartingNumber = 1; section.PageSetup.TopMargin = "2.3cm"; section.PageSetup.BottomMargin = "1.5cm"; section.PageSetup.LeftMargin = "1.27cm"; section.PageSetup.RightMargin = "1.27cm"; section.PageSetup.FooterDistance = "0cm"; HeaderFooter header = section.Headers.Primary; System.Reflection.Assembly asm = System.Reflection.Assembly.GetAssembly(typeof(PDFReport)); String basePath = Path.GetDirectoryName(asm.Location); Image image = header.AddImage(Path.Combine(basePath, "report-safeid-logo.png")); image.Height = "1cm"; image.LockAspectRatio = true; image.RelativeVertical = RelativeVertical.Page; image.RelativeHorizontal = RelativeHorizontal.Margin; image.Top = "0.70cm"; image.Left = ShapePosition.Left; image.WrapFormat.Style = WrapStyle.Through; // Create the text frame for the header TextFrame addressFrame = header.AddTextFrame(); addressFrame.Height = "3.0cm"; addressFrame.Width = "20cm"; addressFrame.Left = ShapePosition.Right; addressFrame.RelativeHorizontal = RelativeHorizontal.Margin; addressFrame.Top = "1.40cm"; addressFrame.RelativeVertical = RelativeVertical.Page; Paragraph headerParagraph = addressFrame.AddParagraph(textHeader); headerParagraph.Format.Font.Name = "Arial"; headerParagraph.Format.Font.Size = 11; headerParagraph.Format.Alignment = ParagraphAlignment.Right; section.Headers.EvenPage.Add(image.Clone()); section.Headers.EvenPage.Add(addressFrame.Clone()); // Create a paragraph with centered page number. See definition of style "Footer". Paragraph paragraph = new Paragraph(); //paragraph.Format.SpaceAfter = "0.1cm"; paragraph.Format.Alignment = ParagraphAlignment.Center; paragraph.Format.Borders.Top.Color = new Color(150, 150, 150); paragraph.Format.Borders.Top.Visible = true; section.Footers.Primary.Add(paragraph); section.Footers.EvenPage.Add(paragraph.Clone()); TextFrame tf = new TextFrame(); tf.Width = "0.8cm"; tf.Height = "0.5cm"; tf.Left = ShapePosition.Right; tf.RelativeHorizontal = RelativeHorizontal.Margin; tf.RelativeVertical = RelativeVertical.Paragraph; tf.MarginTop = "0.2cm"; paragraph = tf.AddParagraph(); paragraph.Format.Font.Size = 10; paragraph.Format.Font.Color = new Color(150, 150, 150); paragraph.Format.Alignment = ParagraphAlignment.Left; paragraph.Format.Borders.Left.Visible = true; paragraph.Format.Borders.Left.Color = new Color(150, 150, 150); paragraph.Format.Borders.DistanceFromLeft = "0.1cm"; paragraph.AddPageField(); section.Footers.Primary.Add(tf); section.Footers.EvenPage.Add(tf.Clone()); tf = new TextFrame(); tf.Width = "10cm"; tf.Height = "0.5cm"; tf.Left = ShapePosition.Right; tf.RelativeHorizontal = RelativeHorizontal.Margin; tf.RelativeVertical = RelativeVertical.Paragraph; tf.MarginTop = "0.2cm"; tf.MarginRight = "1.2cm"; paragraph = tf.AddParagraph(textFooter); paragraph.Format.Font.Size = 9; paragraph.Format.Font.Color = new Color(200, 200, 200); paragraph.Format.Alignment = ParagraphAlignment.Right; section.Footers.Primary.Add(tf); section.Footers.EvenPage.Add(tf.Clone()); }