コード例 #1
0
ファイル: Table.cs プロジェクト: tkrotoff/PDFWriter
        /// <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;
        }
コード例 #2
0
ファイル: PageLayout.cs プロジェクト: tkrotoff/PDFWriter
 internal double GetHeaderRightXPos(string text, Font font)
 {
     double textWidth = FontMetrics.GetTextWidth(text, font);
     return HeaderRightXLimit - textWidth;
 }