public static void AddPrimaryFooter(ref Section sec, bool includedVirginBanner) { sec.PageSetup.DifferentFirstPageHeaderFooter = true; sec.PageSetup.StartingNumber = 1; HeaderFooter MainFooter = sec.Footers.Primary; Table FooterTable = MainFooter.AddTable(); FooterTable.TopPadding = "1mm"; Column c = FooterTable.AddColumn("90mm"); c = FooterTable.AddColumn("90mm"); c = FooterTable.AddColumn("10mm"); Row r = null; Image img = null; Hyperlink h = null; Paragraph p = null; r = FooterTable.AddRow(); r.TopPadding = "0.2mm"; img = r.Cells[0].AddImage("C:\\images\\footer.jfif"); img.Width = "190mm"; img.LockAspectRatio = true; HeaderFooter MainFooterPmy = sec.Footers.Primary; MainFooterPmy.AddImage("C:\\images\\footer.jfif"); }
/// <summary> /// Defines page setup, headers, and footers /// </summary> /// <param name="document">MigraDoc document created via Documents.CreateDocument()</param> public static void DefineContentSection(Document document) { Section section = document.AddSection(); section.PageSetup.TopMargin = "5cm"; section.PageSetup.StartingNumber = 1; section.PageSetup.Orientation = Orientation.Landscape; // Create header HeaderFooter header = section.Headers.Primary; // Add logo Image image = header.AddImage(Report.logoPath); image.Width = "8cm"; image.WrapFormat.Style = WrapStyle.Through; // Add company name Paragraph h1 = new Paragraph(); h1.AddText(Report.companyName); h1.Format.Font.Color = Colors.SlateGray; h1.Format.Font.Size = 24; h1.Format.Font.Bold = true; header.Add(h1); // Add report name Paragraph h2 = new Paragraph(); h2.Format.Font.Color = Colors.SlateGray; h2.AddText("Welfare Check Breach Report"); h2.Format.Font.Size = 18; h2.Format.Borders.Width = 0; h2.Format.Borders.Bottom.Width = 1; h2.Format.Borders.Color = Colors.LightSlateGray; h2.Format.Borders.Distance = 4; header.Add(h2); // Add current date Paragraph h3 = new Paragraph(); h3.Format.Font.Size = 12; h3.Format.Font.Italic = true; h3.Format.Borders.Distance = 6; h3.AddDateField(); header.Add(h3); // Create a paragraph with centered page number. See definition of style "Footer". Paragraph footer = new Paragraph(); footer.Format.Borders.Width = 0; footer.Format.Borders.Top.Width = 1; footer.Format.Borders.Color = Colors.LightSlateGray; footer.Format.Borders.Distance = 10; footer.AddPageField(); // Add paragraph to footer section.Footers.Primary.Add(footer); }
public static void AddNoFooter(ref Section sec) { sec.PageSetup.DifferentFirstPageHeaderFooter = true; sec.PageSetup.StartingNumber = 1; HeaderFooter MainFooter = sec.Footers.FirstPage; Table FooterTable = MainFooter.AddTable(); FooterTable.TopPadding = "1mm"; Column c = FooterTable.AddColumn("160mm"); c = FooterTable.AddColumn("10mm"); c = FooterTable.AddColumn("20mm"); Row r = null; Image img = null; r = FooterTable.AddRow(); r.Cells[0].MergeRight = 2; img = r.Cells[0].AddImage("C:\\images\\transpix.gif"); img.Width = "190mm"; img.Height = "1mm"; r = FooterTable.AddRow(); r.TopPadding = "0.2mm"; img = r.Cells[0].AddImage("C:\\images\\footerplain.jpg"); img.Width = "190mm"; //"45mm"; img.Height = "25mm"; img.LockAspectRatio = true; HeaderFooter MainFooterPmy = sec.Footers.Primary; MainFooterPmy.AddImage("C:\\images\\transpix.gif"); }
/// <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()); }