//create the pdf footer void pdfConvertor_DrawPDFFooter(object sender, PDFHeaderFooterEventArgs e) { PdfPageTemplateElement footer = e.HeaderFooterTemplate; PdfFont font = new PdfStandardFont(PdfFontFamily.Helvetica, 8); PdfSolidBrush brush = new PdfSolidBrush(Color.Gray); PdfPen pen = new PdfPen(Color.DarkBlue, 3f); font = new PdfStandardFont(PdfFontFamily.Helvetica, 6, PdfFontStyle.Bold); PdfStringFormat format = new PdfStringFormat(); format.Alignment = PdfTextAlignment.Center; format.LineAlignment = PdfVerticalAlignment.Middle; footer.Graphics.DrawString("@Copyright 2008", font, brush, new RectangleF(0, footer.Height - 40, footer.Width, footer.Height), format); format = new PdfStringFormat(); format.Alignment = PdfTextAlignment.Right; format.LineAlignment = PdfVerticalAlignment.Bottom; //Create page number field PdfPageNumberField pageNumber = new PdfPageNumberField(font, brush); //Create page count field PdfPageCountField count = new PdfPageCountField(font, brush); PdfCompositeField compositeField = new PdfCompositeField(font, brush, "Page {0} of {1}", pageNumber, count); compositeField.Bounds = footer.Bounds; compositeField.Draw(footer.Graphics, new PointF(470, footer.Height - 10)); }
//create the pdf header void pdfConvertor_DrawPDFHeader(object sender, PDFHeaderFooterEventArgs e) { PdfPageTemplateElement header = e.HeaderFooterTemplate; PdfFont font = new PdfStandardFont(PdfFontFamily.Helvetica, 24); float doubleHeight = font.Height * 2; Color activeColor = Color.FromArgb(44, 71, 120); SizeF imageSize = new SizeF(110f, 35f); //Locating the logo on the right corner of the Drawing Surface PointF imageLocation = new PointF(e.HeaderFooterTemplate.Width - imageSize.Width - 20, 5); PdfImage img = new PdfBitmap(FindImageFile(@"Common\Images\Grid\PDF_logo\logo.png")); //Draw the image in the Header. header.Graphics.DrawImage(img, imageLocation, imageSize); PdfSolidBrush brush = new PdfSolidBrush(activeColor); PdfPen pen = new PdfPen(Color.DarkBlue, 3f); font = new PdfStandardFont(PdfFontFamily.Helvetica, 16, PdfFontStyle.Bold); //Set formattings for the text PdfStringFormat format = new PdfStringFormat(); format.Alignment = PdfTextAlignment.Center; format.LineAlignment = PdfVerticalAlignment.Middle; //Draw title header.Graphics.DrawString("Syncfusion Essential Grid", font, brush, new RectangleF(0, 0, header.Width, header.Height), format); brush = new PdfSolidBrush(Color.Gray); font = new PdfStandardFont(PdfFontFamily.Helvetica, 6, PdfFontStyle.Bold); format = new PdfStringFormat(); format.Alignment = PdfTextAlignment.Left; format.LineAlignment = PdfVerticalAlignment.Bottom; //Draw some lines in the header pen = new PdfPen(Color.DarkBlue, 0.7f); header.Graphics.DrawLine(pen, 0, 0, header.Width, 0); pen = new PdfPen(Color.DarkBlue, 2f); header.Graphics.DrawLine(pen, 0, 03, header.Width + 3, 03); pen = new PdfPen(Color.DarkBlue, 2f); header.Graphics.DrawLine(pen, 0, header.Height - 3, header.Width, header.Height - 3); header.Graphics.DrawLine(pen, 0, header.Height, header.Width, header.Height); }