private void AddFooters() { Font fontHorz = new Font("Tahoma", 7, FontStyle.Bold); StringFormat sfRight = new StringFormat(); sfRight.Alignment = StringAlignment.Far; for (int page = 0; page < PdfCotizacion.Pages.Count; page++) { // select page we want (could change PageSize) PdfCotizacion.CurrentPage = page; // build rectangles for rendering text RectangleF rcPage = GetPageRect(); RectangleF rcFooter = rcPage; rcFooter.Y = rcFooter.Bottom + 6; rcFooter.Height = 12; RectangleF rcVert = rcPage; rcVert.X = rcPage.Right + 6; // add left-aligned footer string text = AppSettings.NomSede + " - " + AppSettings.UbicacionSede + " TEL: " + AppSettings.TelfSede; PdfCotizacion.DrawString(text, fontHorz, Brushes.Black, rcFooter); // add right-aligned footer string TextVertical = string.Format("Page {0} of {1}", page + 1, PdfCotizacion.Pages.Count); PdfCotizacion.DrawString(TextVertical, fontHorz, Brushes.Black, rcFooter, sfRight); // draw lines on bottom and right of the page PdfCotizacion.DrawLine(Pens.Black, rcPage.Left, rcPage.Bottom, rcPage.Right, rcPage.Bottom); } }
internal RectangleF RenderParagraph(string text, Font font, RectangleF rcPage, RectangleF rc, bool outline, int Tipo) { // if it won't fit this page, do a page break rc.Height = PdfCotizacion.MeasureString(text, font, rc.Width).Height; if (rc.Bottom > rcPage.Bottom) { PdfCotizacion.NewPage(); rc.Y = rcPage.Top; } // draw the string StringFormat sf = new StringFormat(); if (Tipo == 1) { sf.Alignment = StringAlignment.Center; sf.LineAlignment = StringAlignment.Center; PdfCotizacion.DrawString(text, font, Brushes.Black, rc, sf); } else if (Tipo == 2) { sf.Alignment = StringAlignment.Near; sf.LineAlignment = StringAlignment.Near; PdfCotizacion.DrawString(text, font, Brushes.Black, rc, sf); } else if (Tipo == 3) { sf.Alignment = StringAlignment.Far; sf.LineAlignment = StringAlignment.Far; PdfCotizacion.DrawString(text, font, Brushes.Black, rc, sf); } //add headings to outline if (outline) { PdfCotizacion.DrawLine(Pens.Black, rc.X, rc.Y, rc.Right, rc.Y); } // update rectangle for next time rc.Offset(0, rc.Height); return(rc); }