public PDFTextBox(PDFText text, int margin, int padding, double xPos, double yPos, string backgroundColor, double width, double height) { _text = text; _margin = margin; _padding = padding; _xPos = xPos; _yPos = yPos; _backgroundColor = backgroundColor; _width = width; _height = height; }
/// <summary> /// Creates the PDF page footer (some text at the bottom of the page). /// </summary> /// <param name="currentPageNumber">Current page number.</param> /// <param name="totalPageNumber">Total number of pages.</param> /// <returns>The PDF page footer as PDFGraphicObjects.</returns> public static List<PDFGraphicObject> CreateFooter(int currentPageNumber, int totalPageNumber) { List<PDFGraphicObject> objects = new List<PDFGraphicObject>(); PDFText footer = new PDFText(PageLayout.LeftFooter, PDFWriter.DefaultFont); PDFTranslation mark = new PDFTranslation( footer, PageLayout.FooterLeftXPos, PageLayout.FooterYPos); objects.Add(mark); string tmp = string.Format( System.Globalization.CultureInfo.InvariantCulture, "Page {0} out of {1}", currentPageNumber, totalPageNumber); footer = new PDFText(tmp, PDFWriter.DefaultFont); mark = new PDFTranslation( footer, PageLayout.GetFooterRightXPos(tmp, PDFWriter.DefaultFont), PageLayout.FooterYPos); objects.Add(mark); return objects; }
/// <summary> /// Creates a row as a PDFGraphicObject. /// </summary> /// <param name="rowName">Title/name of the row.</param> /// <param name="yPos">Y position of the row inside the PDF page.</param> /// <returns>A PDFGraphicObject representing the row.</returns> public static PDFTextBox CreateRow(string rowName, double yPos) { Font font = new Font(Font.Helvetica, 9, Color.Green); // A string should be green int rowNameInt32; bool resultInt32 = Int32.TryParse(rowName, System.Globalization.NumberStyles.Number, System.Globalization.CultureInfo.InvariantCulture, out rowNameInt32); double rowNameDouble; bool resultDouble = Double.TryParse(rowName, System.Globalization.NumberStyles.Number, System.Globalization.CultureInfo.InvariantCulture, out rowNameDouble); if (resultInt32 || resultDouble) { if (rowNameInt32 < 0 || rowNameDouble < 0) { // A negative number should be red font.Color = Color.Red; } else { // A positive number should be blue font.Color = Color.Blue; } } PDFText text = new PDFText(rowName, font); const int margin = 1; const int padding = 1; PDFTextBox box = new PDFTextBox(text, margin, padding, 0, yPos); return box; }
/// <summary> /// Creates a column as a PDFGraphicObject. /// </summary> /// <param name="columnName">Title/name of the column.</param> /// <param name="columnWidth">Column width.</param> /// <returns>A PDFGraphicObject representing the column.</returns> private static PDFTextBox CreateColumn(string columnName, double columnWidth) { PDFText text = new PDFText(columnName, PDFWriter.DefaultFont); double width = columnWidth; const int margin = 1; const int padding = 1; PDFTextBox box = new PDFTextBox( text, margin, padding, 0, 0, PDFWriter.CellBackgroundColor, width, RowHeight); return box; }
public PDFTextBox(PDFText text, int margin, int padding, double xPos, double yPos) : this(text, margin, padding, xPos, yPos, Color.NoColor, 0, 0) { }
/// <summary> /// Creates the PDF page header (some text at the top of the page). /// </summary> /// <returns>The PDF page header as PDFGraphicObjects.</returns> public static List<PDFGraphicObject> CreateHeader() { List<PDFGraphicObject> objects = new List<PDFGraphicObject>(); PDFText header = new PDFText(PageLayout.LeftHeader, PDFWriter.DefaultFont); PDFTranslation mark = new PDFTranslation( header, PageLayout.HeaderLeftXPos, PageLayout.HeaderYPos); objects.Add(mark); header = new PDFText(PageLayout.RightHeader, PDFWriter.DefaultFont); mark = new PDFTranslation( header, PageLayout.GetHeaderRightXPos(PageLayout.RightHeader, PDFWriter.DefaultFont), PageLayout.HeaderYPos); objects.Add(mark); return objects; }
/// <summary> /// Creates the PDF page title (some text at the top of the page). /// </summary> /// <param name="title">PDF page title.</param> /// <param name="xPos">PDF page title X position.</param> /// <param name="yPos">PDF page title Y position.</param> /// <returns>The PDF page title as a PDFGraphicObject.</returns> private static PDFGraphicObject CreatePageTitle(string title, double xPos, double yPos) { PDFText pdfTitle = new PDFText(title, PDFWriter.TitleFont); PDFTranslation mark = new PDFTranslation(pdfTitle, xPos, yPos); return mark; }