示例#1
0
        public override void writePdf(bool bBlackAndWhite = false)
        {
            initFile();

            PdfPTable table;

            iTextSharp.text.Font fNorm = new iTextSharp.text.Font();
            m_iCount = (m_iEnd - m_iStart) / m_iStep;
            if (m_iCount <= 5)
            {
                float[] fWidth = { 4, 10, 10 };
                table      = new PdfPTable(fWidth);
                fNorm.Size = 50;
            }
            else if (m_iCount <= 10)
            {
                float[] fWidth = { 4, 10, 10 };
                table      = new PdfPTable(fWidth);
                fNorm.Size = 30;
            }
            else
            {
                float[] fWidth = { 4, 10, 10 };
                table      = new PdfPTable(fWidth);
                fNorm.Size = 30;
            }
            fNorm.Color = BaseColor.GRAY;
            int cellHeight = ((int)m_doc.PageSize.Height - 200) * m_iStep / (m_iEnd + m_iStep - m_iStart);

            for (int i = m_iStart; i <= m_iEnd; i += m_iStep)
            {
                PdfPCell cell      = new PdfPCell(new Phrase(i.ToString(), fNorm));
                PdfPCell cellWords = new PdfPCell(new Phrase(NumberTranslator.ToWords(i), fNorm));
                cell.MinimumHeight      = cellHeight;
                cellWords.MinimumHeight = cellHeight;
                cell.VerticalAlignment  = Element.ALIGN_MIDDLE;

                cellWords.VerticalAlignment = Element.ALIGN_MIDDLE;
                table.AddCell(cell);
                table.AddCell(cellWords);
                table.AddCell(cellWords);
            }
            m_doc.Add(table);


            printSiteName();
            m_doc.Close();
        }
        public override void writePdf(bool bBlackAndWhite = false)
        {
            initFile();
            {
                PdfPTable table;
                int       cellHeight = ((int)m_doc.PageSize.Height - 200) / m_iCount;
                if (m_strType.Equals("numberstowords"))
                {
                    if (m_iMax < 100)
                    {
                        float[] width = { 2, 10 };
                        table        = new PdfPTable(width);
                        m_fNorm.Size = 50;
                    }
                    else if (m_iMax < 1000)
                    {
                        float[] width = { 2, 10 };
                        table        = new PdfPTable(width);
                        m_fNorm.Size = 20;
                    }
                    else
                    {
                        float[] width = { 2, 10 };
                        table        = new PdfPTable(width);
                        m_fNorm.Size = 20;
                    }
                }
                else
                {
                    float[] width = { 10, 2 };
                    table = new PdfPTable(width);
                    if (m_iMax > 1000)
                    {
                        m_fNorm.Size = 15;
                    }
                    if (m_iMax < 100)
                    {
                        m_fNorm.Size = 30;
                    }
                }

                for (int i = 0; i < m_iCount; i++)
                {
                    int      val  = s_random.Next(1, m_iMax);
                    PdfPCell cell = new PdfPCell();
                    if (i == 0 || m_strType.Equals("numberstowords"))
                    {
                        cell.Phrase = new Phrase(val.ToString(), m_fNorm);
                    }
                    else
                    {
                        cell.Phrase = new Phrase(" ");
                    }
                    cell.HorizontalAlignment = Element.ALIGN_RIGHT;

                    PdfPCell cellWords = new PdfPCell();
                    if (i == 0 || m_strType.Equals("wordstonumbers"))
                    {
                        cellWords.Phrase = new Phrase(NumberTranslator.ToWords(val), m_fNorm);
                    }
                    else
                    {
                        cellWords.Phrase = new Phrase(" ");
                    }

                    cell.MinimumHeight          = cellHeight;
                    cellWords.MinimumHeight     = cellHeight;
                    cell.VerticalAlignment      = Element.ALIGN_MIDDLE;
                    cellWords.VerticalAlignment = Element.ALIGN_MIDDLE;

                    if (m_strType.Equals("numberstowords"))
                    {
                        table.AddCell(cell);
                        table.AddCell(cellWords);
                    }
                    else
                    {
                        table.AddCell(cellWords);
                        table.AddCell(cell);
                    }
                }
                m_doc.Add(table);
            }
            printSiteName();
            m_doc.Close();
        }