Exemple #1
0
        /// <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;
        }
Exemple #2
0
 /// <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;
 }