Inheritance: IAccessibleElement
Exemplo n.º 1
0
        /** Writes the selected rows and columns to the document.
         * This method does not clip the columns; this is only important
         * if there are columns with colspan at boundaries.
         * <P>
         * <CODE>canvases</CODE> is obtained from <CODE>beginWritingRows()</CODE>.
         * <P>
         * The table event is only fired for complete rows.
         * @param colStart the first column to be written, zero index
         * @param colEnd the last column to be written + 1. If it is -1 all the
         * columns to the end are written
         * @param rowStart the first row to be written, zero index
         * @param rowEnd the last row to be written + 1. If it is -1 all the
         * rows to the end are written
         * @param xPos the x write coodinate
         * @param yPos the y write coodinate
         * @param canvases an array of 4 <CODE>PdfContentByte</CODE> obtained from
         * <CODE>beginWrittingRows()</CODE>
         * @return the y coordinate position of the bottom of the last row
         * @see #beginWritingRows(com.lowagie.text.pdf.PdfContentByte)
         */
        public float WriteSelectedRows(int colStart, int colEnd, int rowStart, int rowEnd, float xPos, float yPos, PdfContentByte[] canvases)
        {
            if (totalWidth <= 0)
            {
                throw new ArgumentException("The table width must be greater than zero.");
            }
            int size = rows.Count;

            if (rowEnd < 0)
            {
                rowEnd = size;
            }
            rowEnd = Math.Min(rowEnd, size);
            if (rowStart < 0)
            {
                rowStart = 0;
            }
            if (rowStart >= rowEnd)
            {
                return(yPos);
            }
            if (colEnd < 0)
            {
                colEnd = absoluteWidths.Length;
            }
            colEnd = Math.Min(colEnd, absoluteWidths.Length);
            if (colStart < 0)
            {
                colStart = 0;
            }
            colStart = Math.Min(colStart, absoluteWidths.Length);
            float yPosStart = yPos;

            for (int k = rowStart; k < rowEnd; ++k)
            {
                PdfPRow row = (PdfPRow)rows[k];
                if (row != null)
                {
                    row.WriteCells(colStart, colEnd, xPos, yPos, canvases);
                    yPos -= row.MaxHeights;
                }
            }
            if (tableEvent != null && colStart == 0 && colEnd == absoluteWidths.Length)
            {
                float[] heights = new float[rowEnd - rowStart + 1];
                heights[0] = yPosStart;
                for (int k = rowStart; k < rowEnd; ++k)
                {
                    PdfPRow row = (PdfPRow)rows[k];
                    float   hr  = 0;
                    if (row != null)
                    {
                        hr = row.MaxHeights;
                    }
                    heights[k - rowStart + 1] = heights[k - rowStart] - hr;
                }
                tableEvent.TableLayout(this, GetEventWidths(xPos, rowStart, rowEnd, headersInEvent), heights, headersInEvent ? headerRows : 0, rowStart, canvases);
            }
            return(yPos);
        }
Exemplo n.º 2
0
 /**
  * Makes a copy of an existing row.
  *
  * @param row
  */
 public PdfPRow(PdfPRow row)
 {
     mayNotBreak = row.mayNotBreak;
     maxHeight   = row.maxHeight;
     calculated  = row.calculated;
     cells       = new PdfPCell[row.cells.Length];
     for (int k = 0; k < cells.Length; ++k)
     {
         if (row.cells[k] != null)
         {
             if (row.cells[k] is PdfPHeaderCell)
             {
                 cells[k] = new PdfPHeaderCell((PdfPHeaderCell)row.cells[k]);
             }
             else
             {
                 cells[k] = new PdfPCell(row.cells[k]);
             }
         }
     }
     widths = new float[cells.Length];
     System.Array.Copy(row.widths, 0, widths, 0, cells.Length);
     InitExtraHeights();
     this.id   = row.ID;
     this.role = row.Role;
     if (row.accessibleAttributes != null)
     {
         this.accessibleAttributes = new Dictionary <PdfName, PdfObject>(row.GetAccessibleAttributes());
     }
 }
Exemplo n.º 3
0
 private void WriteAttributes(PdfPRow row)
 {
     if (row != null)
     {
         this.SetAttribute(PdfName.O, PdfName.TABLE);
     }
 }
Exemplo n.º 4
0
        /// <summary>
        /// 创建测试者信息和测试信息表格
        /// </summary>
        /// <param name="tableEle"></param>
        /// <param name="columnCount"></param>
        protected void CreateTestInfoTable(XElement tableEle, int columnCount)
        {
            string    remark         = tableEle.Attribute("remark").Value;
            Paragraph parTableRemark = new Paragraph(remark, fontTableRemark);

            parTableRemark.IndentationLeft = 24;
            parTableRemark.SpacingBefore   = 20;
            pdfDoc.Add(parTableRemark);

            PdfPTable      table   = new iTextSharp.text.pdf.PdfPTable(columnCount);
            List <PdfPRow> rowList = new List <iTextSharp.text.pdf.PdfPRow>();

            foreach (XElement rowEle in tableEle.Elements())
            {
                List <PdfPCell> cellList = new List <iTextSharp.text.pdf.PdfPCell>();
                foreach (XElement cellEle in rowEle.Elements())
                {
                    string label = cellEle.Attribute("label").Value;
                    string value = cellEle.Attribute("value").Value;
                    if (value.Trim().Equals(""))
                    {
                        value = "/";
                    }

                    iTextSharp.text.pdf.PdfPCell cellLabel = new iTextSharp.text.pdf.PdfPCell(new Phrase(label, fontLabel));
                    cellLabel.FixedHeight         = 24;
                    cellLabel.Padding             = 4;
                    cellLabel.HorizontalAlignment = PdfPCell.ALIGN_RIGHT;
                    cellLabel.VerticalAlignment   = PdfPCell.ALIGN_MIDDLE;

                    PdfPCell cellContent = new iTextSharp.text.pdf.PdfPCell(new Phrase(value, fontContent));
                    cellContent.FixedHeight       = 24;
                    cellContent.PaddingTop        = 4;
                    cellContent.VerticalAlignment = PdfPCell.ALIGN_MIDDLE;
                    XAttribute colSpanAtt = cellEle.Attribute("colspan");
                    if (colSpanAtt != null)
                    {
                        string colspan = colSpanAtt.Value;
                        if (colspan != "")
                        {
                            cellContent.Colspan = int.Parse(colspan);
                        }
                    }
                    cellList.Add(cellLabel);
                    cellList.Add(cellContent);
                }
                PdfPRow row = new iTextSharp.text.pdf.PdfPRow(cellList.ToArray <PdfPCell>());
                rowList.Add(row);
            }
            table.Rows.AddRange(rowList);
            table.KeepTogether  = true;
            table.SpacingBefore = 10;
            table.TotalWidth    = 750;
            table.LockedWidth   = true;
            Paragraph pTable = new Paragraph();

            pTable.Add(table);
            pdfDoc.Add(pTable);
        }
Exemplo n.º 5
0
        /** Gets the height of a particular row.
         * @param idx the row index (starts at 0)
         * @return the height of a particular row
         */
        public float getRowHeight(int idx)
        {
            if (totalWidth <= 0 || idx < 0 || idx >= rows.Count)
            {
                return(0);
            }
            PdfPRow row = (PdfPRow)rows[idx];

            return(row.MaxHeights);
        }
Exemplo n.º 6
0
 /**
  * Copies the content of one row to this row.
  * Don't do this if the rows have a different number of cells.
  * @param copy  the row that needs to be copied
  * @since 5.1.0
  */
 public void CopyContent(PdfPRow copy)
 {
     for (int i = 0; i < cells.Length; ++i)
     {
         if (cells[i] != null)
         {
             cells[i].Column = copy.GetCells()[i].Column;
         }
     }
 }
Exemplo n.º 7
0
 internal float [][] GetEventWidths(float xPos, int firstRow, int lastRow, bool includeHeaders)
 {
     if (includeHeaders)
     {
         firstRow = Math.Max(firstRow, headerRows);
         lastRow  = Math.Max(lastRow, headerRows);
     }
     float[][] widths = new float[(includeHeaders ? headerRows : 0) + lastRow - firstRow][];
     if (isColspan)
     {
         int n = 0;
         if (includeHeaders)
         {
             for (int k = 0; k < headerRows; ++k)
             {
                 PdfPRow row = (PdfPRow)rows[k];
                 if (row == null)
                 {
                     ++n;
                 }
                 else
                 {
                     widths[n++] = row.GetEventWidth(xPos);
                 }
             }
         }
         for (; firstRow < lastRow; ++firstRow)
         {
             PdfPRow row = (PdfPRow)rows[firstRow];
             if (row == null)
             {
                 ++n;
             }
             else
             {
                 widths[n++] = row.GetEventWidth(xPos);
             }
         }
     }
     else
     {
         float[] width = new float[absoluteWidths.Length + 1];
         width[0] = xPos;
         for (int k = 0; k < absoluteWidths.Length; ++k)
         {
             width[k + 1] = width[k] + absoluteWidths[k];
         }
         for (int k = 0; k < widths.Length; ++k)
         {
             widths[k] = width;
         }
     }
     return(widths);
 }
Exemplo n.º 8
0
 public PdfPRow(PdfPRow row)
 {
     maxHeight  = row.maxHeight;
     calculated = row.calculated;
     cells      = new PdfPCell[row.cells.Length];
     for (int k = 0; k < cells.Length; ++k)
     {
         if (row.cells[k] != null)
         {
             cells[k] = new PdfPCell(row.cells[k]);
         }
     }
 }
Exemplo n.º 9
0
 /** Deletes a row from the table.
  * @param rowNumber the row to be deleted
  * @return <CODE>true</CODE> if the row was deleted
  */
 public bool deleteRow(int rowNumber)
 {
     if (rowNumber < 0 || rowNumber >= rows.Count)
     {
         return(false);
     }
     if (totalWidth > 0)
     {
         PdfPRow row = (PdfPRow)rows[rowNumber];
         totalHeight -= row.MaxHeights;
     }
     rows.RemoveAt(rowNumber);
     return(true);
 }
Exemplo n.º 10
0
 internal void calculateHeights()
 {
     if (totalWidth <= 0)
     {
         return;
     }
     totalHeight = 0;
     for (int k = 0; k < rows.Count; ++k)
     {
         PdfPRow row = (PdfPRow)rows[k];
         row.setWidths(absoluteWidths);
         totalHeight += row.MaxHeights;
     }
 }
Exemplo n.º 11
0
 /**
 * Returns the height of the cell.
 * @return  the height of the cell
 * @since   3.0.0
 */
 public float GetMaxHeight() {
     bool pivoted = (Rotation == 90 || Rotation == 270);
     Image img = this.Image;
     if (img != null) {
         img.ScalePercent(100);
         float refWidth = pivoted ? img.ScaledHeight : img.ScaledWidth;
         float scale = (Right - EffectivePaddingRight
                 - EffectivePaddingLeft - Left) / refWidth;
         img.ScalePercent(scale * 100);
         float refHeight = pivoted ? img.ScaledWidth : img.ScaledHeight;
         Bottom = Top - EffectivePaddingTop - EffectivePaddingBottom - refHeight;
     }
     else {
         if (pivoted && HasFixedHeight())
             Bottom = Top - FixedHeight;
         else {
             ColumnText ct = ColumnText.Duplicate(Column);
             float right, top, left, bottom;
             if (pivoted) {
                 right = PdfPRow.RIGHT_LIMIT;
                 top = Right - EffectivePaddingRight;
                 left = 0;
                 bottom = Left + EffectivePaddingLeft;
             }
             else {
                 right = NoWrap ? PdfPRow.RIGHT_LIMIT : Right - EffectivePaddingRight;
                 top = Top - EffectivePaddingTop;
                 left = Left + EffectivePaddingLeft;
                 bottom = HasFixedHeight() ? top + EffectivePaddingBottom - FixedHeight : PdfPRow.BOTTOM_LIMIT;
             }
             PdfPRow.SetColumn(ct, left, bottom, right, top);
             ct.Go(true);
             if (pivoted)
                 Bottom = Top - EffectivePaddingTop - EffectivePaddingBottom - ct.FilledWidth;
             else {
                 float yLine = ct.YLine;
                 if (UseDescender)
                     yLine += ct.Descender;
                 Bottom = yLine - EffectivePaddingBottom;
             }
         }
     }
     float height = Height;
     if (HasFixedHeight())
         height = FixedHeight;
     else if (HasMinimumHeight() && height < MinimumHeight)
         height = MinimumHeight;
     return height;
 }
Exemplo n.º 12
0
 /**
  * Makes a copy of an existing row.
  * @param row
  */
 public PdfPRow(PdfPRow row)
 {
     maxHeight  = row.maxHeight;
     calculated = row.calculated;
     cells      = new PdfPCell[row.cells.Length];
     for (int k = 0; k < cells.Length; ++k)
     {
         if (row.cells[k] != null)
         {
             cells[k] = new PdfPCell(row.cells[k]);
         }
     }
     widths = new float[cells.Length];
     Array.Copy(row.widths, 0, widths, 0, cells.Length);
 }
Exemplo n.º 13
0
 public PdfPRow(PdfPCell[] cells, PdfPRow source)
 {
     this.cells = cells;
     widths     = new float[cells.Length];
     InitExtraHeights();
     if (source != null)
     {
         this.id   = source.ID;
         this.role = source.Role;
         if (source.accessibleAttributes != null)
         {
             this.accessibleAttributes = new Dictionary <PdfName, PdfObject>(source.GetAccessibleAttributes());
         }
     }
 }
Exemplo n.º 14
0
 /// <summary>
 /// Makes a copy of an existing row.
 /// </summary>
 /// <param name="row"></param>
 public PdfPRow(PdfPRow row)
 {
     MaxHeight  = row.MaxHeight;
     Calculated = row.Calculated;
     Cells      = new PdfPCell[row.Cells.Length];
     for (var k = 0; k < Cells.Length; ++k)
     {
         if (row.Cells[k] != null)
         {
             Cells[k] = new PdfPCell(row.Cells[k]);
         }
     }
     Widths = new float[Cells.Length];
     Array.Copy(row.Widths, 0, Widths, 0, Cells.Length);
     InitExtraHeights();
 }
Exemplo n.º 15
0
 /**
  * Calculates the heights of the table.
  */
 public void CalculateHeightsFast()
 {
     if (totalWidth <= 0)
     {
         return;
     }
     totalHeight = 0;
     for (int k = 0; k < rows.Count; ++k)
     {
         PdfPRow row = (PdfPRow)rows[k];
         if (row != null)
         {
             totalHeight += row.MaxHeights;
         }
     }
 }
Exemplo n.º 16
0
        /** Adds a cell element.
         * @param cell the cell element
         */
        public void AddCell(PdfPCell cell)
        {
            PdfPCell ncell   = new PdfPCell(cell);
            int      colspan = ncell.Colspan;

            colspan       = Math.Max(colspan, 1);
            colspan       = Math.Min(colspan, currentRow.Length - currentRowIdx);
            ncell.Colspan = colspan;
            if (colspan != 1)
            {
                isColspan = true;
            }
            int rdir = ncell.RunDirection;

            if (rdir == PdfWriter.RUN_DIRECTION_DEFAULT)
            {
                ncell.RunDirection = runDirection;
            }
            currentRow[currentRowIdx] = ncell;
            currentRowIdx            += colspan;
            if (currentRowIdx >= currentRow.Length)
            {
                if (runDirection == PdfWriter.RUN_DIRECTION_RTL)
                {
                    PdfPCell[] rtlRow = new PdfPCell[absoluteWidths.Length];
                    int        rev    = currentRow.Length;
                    for (int k = 0; k < currentRow.Length; ++k)
                    {
                        PdfPCell rcell = currentRow[k];
                        int      cspan = rcell.Colspan;
                        rev        -= cspan;
                        rtlRow[rev] = rcell;
                        k          += cspan - 1;
                    }
                    currentRow = rtlRow;
                }
                PdfPRow row = new PdfPRow(currentRow);
                if (totalWidth > 0)
                {
                    row.SetWidths(absoluteWidths);
                    totalHeight += row.MaxHeights;
                }
                rows.Add(row);
                currentRow    = new PdfPCell[absoluteWidths.Length];
                currentRowIdx = 0;
            }
        }
Exemplo n.º 17
0
 /** Constructs a copy of a <CODE>PdfPTable</CODE>.
  * @param table the <CODE>PdfPTable</CODE> to be copied
  */
 public PdfPTable(PdfPTable table)
 {
     CopyFormat(table);
     for (int k = 0; k < currentRow.Length; ++k)
     {
         if (table.currentRow[k] == null)
         {
             break;
         }
         currentRow[k] = new PdfPCell(table.currentRow[k]);
     }
     for (int k = 0; k < table.rows.Count; ++k)
     {
         PdfPRow row = (PdfPRow)(table.rows[k]);
         if (row != null)
         {
             row = new PdfPRow(row);
         }
         rows.Add(row);
     }
 }
Exemplo n.º 18
0
        /**
         * Writes the selected rows to the document.
         * <P>
         * <CODE>canvases</CODE> is obtained from <CODE>beginWrittingRows()</CODE>.
         * @param rowStart the first row to be written, zero index
         * @param rowEnd the last row to be written - 1. If it is -1 all the
         * rows to the end are written
         * @param xPos the x write coodinate
         * @param yPos the y write coodinate
         * @param canvases an array of 4 <CODE>PdfContentByte</CODE> obtained from
         * <CODE>beginWrittingRows()</CODE>
         * @return the y coordinate position of the bottom of the last row
         * @see #beginWritingRows(iTextSharp.text.pdf.PdfContentByte)
         */
        public float writeSelectedRows(int rowStart, int rowEnd, float xPos, float yPos, PdfContentByte[] canvases)
        {
            if (totalWidth <= 0)
            {
                throw new RuntimeException("The table width must be greater than zero.");
            }
            int size = rows.Count;

            if (rowEnd < 0)
            {
                rowEnd = size;
            }
            if (rowStart >= size || rowStart >= rowEnd)
            {
                return(yPos);
            }
            rowEnd = Math.Min(rowEnd, size);
            float yPosStart = yPos;

            for (int k = rowStart; k < rowEnd; ++k)
            {
                PdfPRow row = (PdfPRow)rows[k];
                row.writeCells(xPos, yPos, canvases);
                yPos -= row.MaxHeights;
            }
            if (tableEvent != null)
            {
                float[] heights = new float[rowEnd - rowStart + 1];
                heights[0] = yPosStart;
                for (int k = rowStart; k < rowEnd; ++k)
                {
                    PdfPRow row = (PdfPRow)rows[k];
                    heights[k - rowStart + 1] = heights[k - rowStart] - row.MaxHeights;
                }
                tableEvent.tableLayout(this, getEventWidths(xPos, rowStart, rowEnd, false), heights, 0, rowStart, canvases);
            }
            return(yPos);
        }
    protected void Prepare_Print()
    {
        String[] weekDays = new String[] { " ","Sun", "Mon", "Tue", "Wed", "Thu" };
        int[] sessions = new int[] {0,1,2,3,4,5,6,7,8,9};
        PdfPTable tblSchedule = new PdfPTable(10);
        PdfPRow[] tempRow = new PdfPRow[6];
        PdfPCell[][] tempCell = new PdfPCell[6][];
        int rowIndex = 0;
        int cellIndex = 0;
        Paragraph subject = new Paragraph();
        Paragraph teacher = new Paragraph();
        Paragraph lunch = new Paragraph();
        Paragraph dayPara = new Paragraph();
        Paragraph sessionPara = new Paragraph();
        Paragraph teacherPara = new Paragraph();

        Font lunch_font = new Font();
        Font day_session_para = new Font();
        Font session_font = new Font();
        Font teacher_font = new Font();

        session_font.Size = 10;
        teacher_font.SetStyle("Italics");
        teacher_font.Size = 7;

        lunch_font.SetColor(153, 153, 255);
        lunch_font.SetStyle("italics");
        lunch = new Paragraph("Lunch", lunch_font);

        day_session_para.SetColor(0, 0, 153);

        foreach (String weekDay in weekDays)
        {
            tempCell[rowIndex] = new PdfPCell[10];
            tempRow[rowIndex] = new PdfPRow(tempCell[rowIndex]);
            foreach (int session in sessions)
            {
                if (session == 0 || session == 6)
                {
                    if (session == 0)
                    {
                        dayPara = new Paragraph(weekDays[rowIndex],day_session_para);
                        tempCell[rowIndex][cellIndex] = new PdfPCell(dayPara);
                    }
                    else
                        if (weekDay != " ")
                        {
                            tempCell[rowIndex][cellIndex] = new PdfPCell(lunch);
                        }
                        else
                        {
                            //tempCell[rowIndex][cellIndex] = new PdfPCell(new Phrase(Convert.ToString(sessions[cellIndex])));
                            dayPara = new Paragraph(Convert.ToString(sessions[cellIndex]), day_session_para);
                            tempCell[rowIndex][cellIndex] = new PdfPCell(dayPara);
                        }
                }
                else
                {
                    if (weekDay == " ")
                    {
                        dayPara = new Paragraph(Convert.ToString(sessions[cellIndex]), day_session_para);
                        tempCell[rowIndex][cellIndex] = new PdfPCell(dayPara);
                        //tempCell[rowIndex][cellIndex] = new PdfPCell(new Phrase(Convert.ToString(sessions[cellIndex])));
                    }
                    else
                    {
                        string query = "select B.CourseTitle,A.TeacherID from tblStudentCourseMap as A,tblCourses as B where A.ComCod = B.ComCod and A.DaySession = '" + weekDay + session + "' and A.StudentID = '" + Current_User_ID + "'";
                        myCon.ConOpen();
                        SqlDataReader sessionDet = myCon.ExecuteReader(query);

                        if (sessionDet.Read())
                            if (!sessionDet.IsDBNull(0))
                            {
                                sessionPara = new Paragraph(sessionDet.GetString(0), session_font);
                                //tempCell[rowIndex][cellIndex] = new PdfPCell(sessionPara);
                                teacherPara = new Paragraph(sessionDet.GetString(1), teacher_font);
                                tempCell[rowIndex][cellIndex] = new PdfPCell(new Phrase(sessionPara));
                                tempCell[rowIndex][cellIndex].Phrase.Add(new Phrase("\n"));
                                tempCell[rowIndex][cellIndex].Phrase.Add(teacherPara);
                                //tempCell[rowIndex][cellIndex] = new PdfPCell(new Phrase(sessionDet.GetString(0) + "\n" + sessionDet.GetString(1)));
                            }
                            else
                            {
                                tempCell[rowIndex][cellIndex] = new PdfPCell(new Phrase(""));
                                //tempCell[rowIndex][cellIndex
                            }
                        else
                            tempCell[rowIndex][cellIndex] = new PdfPCell(new Phrase(""));
                        myCon.ConClose();
                        tempCell[rowIndex][cellIndex].FixedHeight = 75;
                    }

                }

                //tempCell[rowIndex][cellIndex].Width = 50;
                cellIndex++;
                //tempRow[rowIndex].Cells.Add(tempCell[cellIndex++, rowIndex]);
            }
            cellIndex = 0;
            //rowIndex++;
            tblSchedule.Rows.Add(tempRow[rowIndex++]);
        }

        Font HeaderFont = new Font();
        Font HeadingFont = new Font();
        HeaderFont.Size = 20;
        HeaderFont.SetStyle(Font.UNDERLINE);
        HeadingFont.Size = 15;
        HeadingFont.SetStyle(Font.UNDERLINE);
        Paragraph HeaderPara = new Paragraph("BITS PILANI, DUBAI OFFCAMPUS - TIMETABLE", HeaderFont);
        Paragraph HeadingPara = new Paragraph("Time Table allotment for " + Current_User_ID + ".",HeadingFont);
        HeaderPara.Alignment = HeadingPara.Alignment = 1;

        Document rptTimetable = new Document(PageSize.A4_LANDSCAPE.Rotate());
        PdfWriter.GetInstance(rptTimetable, new FileStream(Request.PhysicalApplicationPath + "\\" + Current_User_ID + "_timetable.pdf", FileMode.Create));
        rptTimetable.Open();
        rptTimetable.AddCreationDate();
        rptTimetable.AddHeader("BITS PILANI, DUBAI OFFCAMPUS", "TIMETABLE");
        rptTimetable.Add(new Paragraph("\n"));
        rptTimetable.AddTitle("BITS PILANI, DUBAI OFFCAMPUS - TIMETABLE");
        rptTimetable.Add(HeaderPara);
        rptTimetable.Add(HeadingPara);
        rptTimetable.Add(new Paragraph("\n\n"));

        if (rptTimetable != null && tblSchedule != null)
        {
            rptTimetable.Add(tblSchedule);
        }
        rptTimetable.Close();
        Response.Redirect("~\\" + Current_User_ID + "_timetable.pdf");
    }
Exemplo n.º 20
0
        private void WriteAttributes(PdfPRow row) {
            if (row != null) {

            }
        }
Exemplo n.º 21
0
        /**
         * Splits a row to newHeight.
         * The returned row is the remainder. It will return null if the newHeight
         * was so small that only an empty row would result.
         *
         * @param new_height the new height
         * @return the remainder row or null if the newHeight was so small that only
         * an empty row would result
         */
        public PdfPRow SplitRow(PdfPTable table, int rowIndex, float new_height)
        {
            // second part of the row
            PdfPCell[] newCells = new PdfPCell[cells.Length];
            float[]    fixHs    = new float[cells.Length];
            float[]    minHs    = new float[cells.Length];
            bool       allEmpty = true;

            // loop over all the cells
            for (int k = 0; k < cells.Length; ++k)
            {
                float    newHeight = new_height;
                PdfPCell cell      = cells[k];
                if (cell == null)
                {
                    int index = rowIndex;
                    if (table.RowSpanAbove(index, k))
                    {
                        while (table.RowSpanAbove(--index, k))
                        {
                            newHeight += table.GetRow(index).MaxHeights;
                        }
                        PdfPRow row = table.GetRow(index);
                        if (row != null && row.GetCells()[k] != null)
                        {
                            newCells[k]         = new PdfPCell(row.GetCells()[k]);
                            newCells[k].Column  = null;
                            newCells[k].Rowspan = row.GetCells()[k].Rowspan - rowIndex + index;
                            allEmpty            = false;
                        }
                    }
                    continue;
                }
                fixHs[k] = cell.FixedHeight;
                minHs[k] = cell.MinimumHeight;
                Image    img     = cell.Image;
                PdfPCell newCell = new PdfPCell(cell);
                if (img != null)
                {
                    if (newHeight > cell.EffectivePaddingBottom + cell.EffectivePaddingTop + 2)
                    {
                        newCell.Phrase = null;
                        allEmpty       = false;
                    }
                }
                else
                {
                    float      y;
                    ColumnText ct     = ColumnText.Duplicate(cell.Column);
                    float      left   = cell.Left + cell.EffectivePaddingLeft;
                    float      bottom = cell.Top + cell.EffectivePaddingBottom - newHeight;
                    float      right  = cell.Right - cell.EffectivePaddingRight;
                    float      top    = cell.Top - cell.EffectivePaddingTop;
                    switch (cell.Rotation)
                    {
                    case 90:
                    case 270:
                        y = SetColumn(ct, bottom, left, top, right);
                        break;

                    default:
                        y = SetColumn(ct, left, bottom + 0.00001f, cell.NoWrap ? RIGHT_LIMIT : right, top);
                        break;
                    }
                    int status;
                    status = ct.Go(true);
                    bool thisEmpty = (ct.YLine == y);
                    if (thisEmpty)
                    {
                        newCell.Column = ColumnText.Duplicate(cell.Column);
                        ct.FilledWidth = 0;
                    }
                    else if ((status & ColumnText.NO_MORE_TEXT) == 0)
                    {
                        newCell.Column = ct;
                        ct.FilledWidth = 0;
                    }
                    else
                    {
                        newCell.Phrase = null;
                    }
                    allEmpty = (allEmpty && thisEmpty);
                }
                newCells[k]      = newCell;
                cell.FixedHeight = newHeight;
            }
            if (allEmpty)
            {
                for (int k = 0; k < cells.Length; ++k)
                {
                    PdfPCell cell = cells[k];
                    if (cell == null)
                    {
                        continue;
                    }
                    if (fixHs[k] > 0)
                    {
                        cell.FixedHeight = fixHs[k];
                    }
                    else
                    {
                        cell.MinimumHeight = minHs[k];
                    }
                }
                return(null);
            }
            CalculateHeights();
            PdfPRow split = new PdfPRow(newCells);

            split.widths = (float[])widths.Clone();
            return(split);
        }
Exemplo n.º 22
0
 /**
 * Constructs a RtfRow for a Row.
 * 
 * @param doc The RtfDocument this RtfRow belongs to
 * @param rtfTable The RtfTable this RtfRow belongs to
 * @param row The Row this RtfRow is based on
 * @param rowNumber The number of this row
 * @since 2.1.3
 */
 protected internal RtfRow(RtfDocument doc, RtfTable rtfTable, PdfPRow row, int rowNumber) : base(doc) {
     this.parentTable = rtfTable;
     this.rowNumber = rowNumber;
     ImportRow(row);
 }
Exemplo n.º 23
0
 /**
 * Splits a row to newHeight.
 * The returned row is the remainder. It will return null if the newHeight
 * was so small that only an empty row would result.
 *
 * @param new_height the new height
 * @return the remainder row or null if the newHeight was so small that only
 * an empty row would result
 */
 public PdfPRow SplitRow(PdfPTable table, int rowIndex, float new_height)
 {
     // second part of the row
     PdfPCell[] newCells = new PdfPCell[cells.Length];
     float[] fixHs = new float[cells.Length];
     float[] minHs = new float[cells.Length];
     bool allEmpty = true;
     // loop over all the cells
     for (int k = 0; k < cells.Length; ++k) {
         float newHeight = new_height;
         PdfPCell cell = cells[k];
         if (cell == null) {
             int index = rowIndex;
             if (table.RowSpanAbove(index, k)) {
                 while (table.RowSpanAbove(--index, k)) {
                     newHeight += table.GetRow(index).MaxHeights;
                 }
                 PdfPRow row = table.GetRow(index);
                 if (row != null && row.GetCells()[k] != null) {
                     newCells[k] = new PdfPCell(row.GetCells()[k]);
                     newCells[k].Column = null;
                     newCells[k].Rowspan = row.GetCells()[k].Rowspan - rowIndex + index;
                     allEmpty = false;
                 }
             }
             continue;
         }
         fixHs[k] = cell.FixedHeight;
         minHs[k] = cell.MinimumHeight;
         Image img = cell.Image;
         PdfPCell newCell = new PdfPCell(cell);
         if (img != null) {
             if (newHeight > cell.EffectivePaddingBottom + cell.EffectivePaddingTop + 2) {
                 newCell.Phrase = null;
                 allEmpty = false;
             }
         }
         else {
             float y;
             ColumnText ct = ColumnText.Duplicate(cell.Column);
             float left = cell.Left + cell.EffectivePaddingLeft;
             float bottom = cell.Top + cell.EffectivePaddingBottom - newHeight;
             float right = cell.Right - cell.EffectivePaddingRight;
             float top = cell.Top - cell.EffectivePaddingTop;
             switch (cell.Rotation) {
                 case 90:
                 case 270:
                     y = SetColumn(ct, bottom, left, top, right);
                     break;
                 default:
                     y = SetColumn(ct, left, bottom + 0.00001f, cell.NoWrap ? RIGHT_LIMIT : right, top);
                     break;
             }
             int status;
             status = ct.Go(true);
             bool thisEmpty = (ct.YLine == y);
             if (thisEmpty) {
                 newCell.Column = ColumnText.Duplicate(cell.Column);
                 ct.FilledWidth = 0;
             }
             else if ((status & ColumnText.NO_MORE_TEXT) == 0) {
                 newCell.Column = ct;
                 ct.FilledWidth = 0;
             }
             else
                 newCell.Phrase = null;
             allEmpty = (allEmpty && thisEmpty);
         }
         newCells[k] = newCell;
         cell.FixedHeight = newHeight;
     }
     if (allEmpty) {
         for (int k = 0; k < cells.Length; ++k) {
             PdfPCell cell = cells[k];
             if (cell == null)
                 continue;
             if (fixHs[k] > 0)
                 cell.FixedHeight = fixHs[k];
             else
                 cell.MinimumHeight = minHs[k];
         }
         return null;
     }
     CalculateHeights();
     PdfPRow split = new PdfPRow(newCells);
     split.widths = (float[]) widths.Clone();
     return split;
 }
Exemplo n.º 24
0
 /**
 * Makes a copy of an existing row.
 * 
 * @param row
 */
 public PdfPRow(PdfPRow row) {
     mayNotBreak = row.mayNotBreak;
     maxHeight = row.maxHeight;
     calculated = row.calculated;
     cells = new PdfPCell[row.cells.Length];
     for (int k = 0; k < cells.Length; ++k) {
         if (row.cells[k] != null)
         {
             if (row.cells[k] is PdfPHeaderCell)
                 cells[k] = new PdfPHeaderCell((PdfPHeaderCell)row.cells[k]);
             else
                 cells[k] = new PdfPCell(row.cells[k]);
         }
     }
     widths = new float[cells.Length];
     System.Array.Copy(row.widths, 0, widths, 0, cells.Length);
     InitExtraHeights();
     this.id = row.ID;
     this.role = row.Role;
     if (row.accessibleAttributes != null)
         this.accessibleAttributes = new Dictionary<PdfName, PdfObject>(row.GetAccessibleAttributes());
 }
        private static PdfPTable CreateReportTable(IGrouping<GroupingByDate, Income> sales)
        {
            var dataTable = new PdfPTable(new float[] { 2, 1, 1.5f, 3.5f, 1 });
            dataTable.WidthPercentage = 100f;
            Font dateFont = FontFactory.GetFont("Arial", 11);
            // var date = sales.Key.Year + "-" +
            //     sales.Key.Month.ToString().PadLeft(2, '0') + "-" +
            //     sales.Key.Day.ToString().PadLeft(2, '0');

            var date = sales.First().Date.ToString("dd-MMM-yyyy");

            var dateParagraph = new Paragraph("Date: " + date, dateFont);
            var dateCell = new PdfPCell(dateParagraph);
            dateCell.Padding = 5;
            dateCell.Colspan = 5;
            dateCell.BackgroundColor = new BaseColor(243, 243, 243);
            dataTable.AddCell(dateCell);

            var headerFont = FontFactory.GetFont("Arial", 10, Font.BOLD);
            var productCell = new PdfPCell(new Paragraph("Product", headerFont));
            var quantityCell = new PdfPCell(new Paragraph("Quantity", headerFont));
            var unitPriceCell = new PdfPCell(new Paragraph("Unit Price", headerFont));
            var locationCell = new PdfPCell(new Paragraph("Location", headerFont));
            var sumCell = new PdfPCell(new Paragraph("Sum", headerFont));
            var headerCells = new PdfPCell[] { productCell, quantityCell, unitPriceCell, locationCell, sumCell };
            foreach (var cell in headerCells)
            {
                cell.BackgroundColor = new BaseColor(200, 200, 200);
                cell.Padding = 5;
            }
            var headerRow = new PdfPRow(headerCells);
            dataTable.Rows.Add(headerRow);

            var dataFont = FontFactory.GetFont("Arial", 10);
            decimal total = 0;
            foreach (var sale in sales)
            {
                var productDataCell = new PdfPCell(new Paragraph(sale.Product.Name, dataFont));
                var quantityDataCell = new PdfPCell(new Paragraph(sale.Quantity.ToString() + " " + sale.Product.Measure.Name, dataFont));
                var unitPriceDataCell = new PdfPCell(new Paragraph(sale.SalePrice.ToString(), dataFont));
                var locationDataCell = new PdfPCell(new Paragraph(sale.Supermarket.Name, dataFont));
                var sum = ((decimal)sale.Quantity * sale.SalePrice);
                var sumDataCell = new PdfPCell(new Paragraph(sum.ToString(), dataFont));
                var dataCells = new PdfPCell[] { productDataCell, quantityDataCell, unitPriceDataCell, locationDataCell, sumDataCell };

                foreach (var cell in dataCells)
                {
                    cell.Padding = 5;
                }
                var dataRow = new PdfPRow(dataCells);
                dataTable.Rows.Add(dataRow);
                total += sum;
            }

            Font totalSumFont = FontFactory.GetFont("Arial", 11, Font.BOLD);
            var footerTotal = new PdfPCell(new Paragraph("Total sum for " + date + ":", dataFont));
            footerTotal.Colspan = 4;
            footerTotal.HorizontalAlignment = Element.ALIGN_RIGHT;
            footerTotal.Padding = 5;
            dataTable.AddCell(footerTotal);
            var footerSum = new PdfPCell(new Paragraph(total.ToString(), totalSumFont));
            footerSum.Padding = 5;
            dataTable.AddCell(footerSum);

            return dataTable;
        }
Exemplo n.º 26
0
        /**
         * Splits a row to newHeight. The returned row is the remainder. It will
         * return null if the newHeight was so small that only an empty row would
         * result.
         *
         * @param newHeight
         *            the new height
         * @return the remainder row or null if the newHeight was so small that only
         *         an empty row would result
         */
        public PdfPRow SplitRow(float newHeight)
        {
            PdfPCell[] newCells = new PdfPCell[cells.Length];
            float[]    fh       = new float[cells.Length * 2];
            bool       allEmpty = true;

            for (int k = 0; k < cells.Length; ++k)
            {
                PdfPCell cell = cells[k];
                if (cell == null)
                {
                    continue;
                }
                fh[k * 2]     = cell.FixedHeight;
                fh[k * 2 + 1] = cell.MinimumHeight;
                Image    img = cell.Image;
                PdfPCell c2  = new PdfPCell(cell);
                if (img != null)
                {
                    if (newHeight > cell.EffectivePaddingBottom
                        + cell.EffectivePaddingTop + 2)
                    {
                        c2.Phrase = null;
                        allEmpty  = false;
                    }
                }
                else
                {
                    int        status;
                    float      y;
                    ColumnText ct = ColumnText.Duplicate(cell.Column);
                    if (cell.Rotation == 90 || cell.Rotation == 270)
                    {
                        y = SetColumn(ct,
                                      cell.Top - newHeight + cell.EffectivePaddingBottom,
                                      cell.Left + cell.EffectivePaddingLeft,
                                      cell.Top - cell.EffectivePaddingTop,
                                      cell.Right - cell.EffectivePaddingRight);
                    }
                    else
                    {
                        float rightLimit = cell.NoWrap ? 20000 : cell.Right
                                           - cell.EffectivePaddingRight;
                        float y1 = cell.Top - newHeight
                                   + cell.EffectivePaddingBottom;
                        float y2 = cell.Top - cell.EffectivePaddingTop;
                        y = Math.Max(y1, y2);
                        y = SetColumn(ct,
                                      cell.Left + cell.EffectivePaddingLeft, y1,
                                      rightLimit, y2);
                    }
                    status = ct.Go(true);
                    bool thisEmpty = (ct.YLine == y);
                    if (thisEmpty)
                    {
                        ct = ColumnText.Duplicate(cell.Column);
                    }
                    allEmpty = (allEmpty && thisEmpty);
                    if ((status & ColumnText.NO_MORE_TEXT) == 0 || thisEmpty)
                    {
                        c2.Column      = ct;
                        ct.FilledWidth = 0;
                    }
                    else
                    {
                        c2.Phrase = null;
                    }
                }
                newCells[k]      = c2;
                cell.FixedHeight = newHeight;
            }
            if (allEmpty)
            {
                for (int k = 0; k < cells.Length; ++k)
                {
                    PdfPCell cell = cells[k];
                    if (cell == null)
                    {
                        continue;
                    }
                    float f = fh[k * 2];
                    float m = fh[k * 2 + 1];
                    if (f <= 0)
                    {
                        cell.MinimumHeight = m;
                    }
                    else
                    {
                        cell.FixedHeight = f;
                    }
                }
                return(null);
            }
            CalculateHeights();
            PdfPRow split = new PdfPRow(newCells);

            split.widths = (float[])widths.Clone();
            split.CalculateHeights();
            return(split);
        }
Exemplo n.º 27
0
        public Boolean generatePdf(String fileName, List<encuesta> e, resultado r)
        {
            try
            {
                new Utils.DeleteFile().deleteFile(@HttpContext.Current.Server.MapPath("~/Utils/pdfs/"));
                var colaborador = new EmpleadoDB().listAll(r.id_empleado);
                var evaluador = new EvaluadorDB().listAll(r.id_evaluador);

                var document = new Document(PageSize.LETTER);
                var pdfwriter = PdfWriter.GetInstance(document, new FileStream(@HttpContext.Current.Server.MapPath("~/Utils/pdfs/" + fileName), FileMode.Create));
                document.Open();
                String[] heads = { "ÁREA DEL DESEMPEÑO", "MUY BAJO", "BAJO", "MEDIO", "ALTO", "MUY ALTO" };
                String[] subHeads = { "", "1", "2", "3", "4", "5" };

                // Creamos el tipo de Font que vamos utilizar
                iTextSharp.text.Font docFont = new iTextSharp.text.Font(iTextSharp.text.Font.FontFamily.HELVETICA, 8, iTextSharp.text.Font.NORMAL, BaseColor.BLACK);
                iTextSharp.text.Font docFont1 = new iTextSharp.text.Font(iTextSharp.text.Font.FontFamily.HELVETICA, 8, iTextSharp.text.Font.BOLD, BaseColor.BLACK);

                document.Add(new Paragraph("Colaborador : " + colaborador[0].nombres + " " + colaborador[0].apellidos));
                document.Add(new Paragraph("Evaluador : " + evaluador[0].nombres + " " + evaluador[0].apellidos));
                document.Add(new Paragraph("Fecha : " + DateTime.Now.ToShortDateString()));
                document.Add(Chunk.NEWLINE);

                var tblEncuesta = new PdfPTable(heads.Length);
                float[] colWidth = { 1000, 150, 150, 150, 150, 150 };
                tblEncuesta.SetWidths(colWidth);
                tblEncuesta.WidthPercentage = 100;

                PdfPCell[] rowCell = new PdfPCell[heads.Length];
                for (var i = 0; i < heads.Length; i++)
                {
                    var pdfCell = new PdfPCell(new Phrase(heads[i], docFont1)) { HorizontalAlignment = Element.ALIGN_CENTER, BorderWidth = 0.75f, FixedHeight = 15f, BackgroundColor = new BaseColor(230, 230, 230) };
                    if (i == 0)
                    {
                        pdfCell.Rowspan = 2;
                        pdfCell.VerticalAlignment = Element.ALIGN_MIDDLE;
                        pdfCell.BorderWidthBottom = 0;
                    }
                    rowCell[i] = pdfCell;
                }
                var row1 = new PdfPRow(rowCell);
                tblEncuesta.Rows.Add(row1);

                PdfPCell[] rowCell1 = new PdfPCell[subHeads.Length];
                for (var i = 0; i < subHeads.Length; i++)
                {
                    var pdfCell = new PdfPCell(new Phrase(subHeads[i], docFont)) { BorderWidth = 0.75f, HorizontalAlignment = Element.ALIGN_CENTER, FixedHeight = 15f };
                    if (i == 0) pdfCell.BorderWidthTop = 0;
                    rowCell1[i] = pdfCell;
                }

                var row2 = new PdfPRow(rowCell1);
                tblEncuesta.Rows.Add(row2);

                //body table
                for (var i = 0; i < e.Count; i++)
                {
                    PdfPCell[] rowBody = new PdfPCell[heads.Length];
                    for (int c = 0; c < heads.Length; c++)
                    {
                        PdfPCell cell;
                        if (c == 0)
                        {
                            if (e[i].id_pregunta == 0)
                            {
                                cell = new PdfPCell(new Phrase(e[i].descripcion, docFont1)) { BorderWidth = 0.75f, FixedHeight = 15f };
                                cell.Colspan = 6;
                                cell.BackgroundColor = new BaseColor(230, 230, 230);

                            }
                            else
                                cell = new PdfPCell(new Phrase(e[i].descripcion, docFont)) { BorderWidth = 0.75f, FixedHeight = 15f };
                        }
                        else
                        {
                            if (c == e[i].puntaje)
                                cell = new PdfPCell(new Phrase(e[i].puntaje.ToString(), docFont)) { BorderWidth = 0.75f, HorizontalAlignment = Element.ALIGN_CENTER, FixedHeight = 15f };
                            else
                                cell = new PdfPCell(new Phrase(" ", docFont)) { BorderWidth = 0.75f, HorizontalAlignment = Element.ALIGN_CENTER, FixedHeight = 15f };
                        }
                        rowBody[c] = cell;
                    }
                    var row3 = new PdfPRow(rowBody);
                    tblEncuesta.Rows.Add(row3);
                }
                document.Add(tblEncuesta);

                document.Close();
                pdfwriter.Close();

                return true;
            }
            catch (Exception)
            {
                throw;
            }
        }
Exemplo n.º 28
0
 /** Adds a cell element.
 * @param cell the cell element
 */
 public void AddCell(PdfPCell cell)
 {
     PdfPCell ncell = new PdfPCell(cell);
     int colspan = ncell.Colspan;
     colspan = Math.Max(colspan, 1);
     colspan = Math.Min(colspan, currentRow.Length - currentRowIdx);
     ncell.Colspan = colspan;
     if (colspan != 1)
         isColspan = true;
     int rdir = ncell.RunDirection;
     if (rdir == PdfWriter.RUN_DIRECTION_DEFAULT)
         ncell.RunDirection = runDirection;
     currentRow[currentRowIdx] = ncell;
     currentRowIdx += colspan;
     if (currentRowIdx >= currentRow.Length) {
         if (runDirection == PdfWriter.RUN_DIRECTION_RTL) {
             PdfPCell[] rtlRow = new PdfPCell[absoluteWidths.Length];
             int rev = currentRow.Length;
             for (int k = 0; k < currentRow.Length; ++k) {
                 PdfPCell rcell = currentRow[k];
                 int cspan = rcell.Colspan;
                 rev -= cspan;
                 rtlRow[rev] = rcell;
                 k += cspan - 1;
             }
             currentRow = rtlRow;
         }
         PdfPRow row = new PdfPRow(currentRow);
         if (totalWidth > 0) {
             row.SetWidths(absoluteWidths);
             totalHeight += row.MaxHeights;
         }
         rows.Add(row);
         currentRow = new PdfPCell[absoluteWidths.Length];
         currentRowIdx = 0;
     }
 }
Exemplo n.º 29
0
        /** Constructs a copy of a <CODE>PdfPTable</CODE>.
        * @param table the <CODE>PdfPTable</CODE> to be copied
        */

        public PdfPTable(PdfPTable table)
        {
            CopyFormat(table);
            for (int k = 0; k < currentRow.Length; ++k)
            {
                if (table.currentRow[k] == null)
                    break;
                currentRow[k] = new PdfPCell(table.currentRow[k]);
            }
            for (int k = 0; k < table.rows.Count; ++k)
            {
                PdfPRow row = table.rows[k];
                if (row != null)
                    row = new PdfPRow(row);
                rows.Add(row);
            }
        }
Exemplo n.º 30
0
 private void WriteAttributes(PdfPRow row)
 {
     if (row != null)
         this.SetAttribute(PdfName.O, PdfName.TABLE);
 }
Exemplo n.º 31
0
        protected void btnPDF_Click2(object sender, EventArgs e)
        {
            try
            {
                string CurrentDate = Convert.ToDateTime(lblDate2.Text).ToString("MM-dd-yyyy") + Convert.ToDateTime(lblDate2.Text).ToString("hhmmsstt");
                string Location = Session["LocationName"].ToString();
                string PayrollDate = "PAYROLL REPORT " + lblWeekPayrollReport.Text;
                string filepath = Server.MapPath("~/Payroll/" + Location + "/" + CurrentDate + "/");
                if (!System.IO.Directory.Exists(filepath))
                {
                    System.IO.Directory.CreateDirectory(filepath);
                }
                if (ddlLocation.SelectedItem.Text == "INDG" || ddlLocation.SelectedItem.Value == "INBH")
                {
                    var pdfDoc = new Document(PageSize.A3);
                    PdfWriter.GetInstance(pdfDoc, new FileStream(filepath + "Payroll" + CurrentDate + ".pdf", FileMode.Create));
                    Session["FilePath"] = filepath + "Payroll" + CurrentDate + ".pdf";
                    Session["filename"] = "Payroll" + CurrentDate + ".pdf";
                    pdfDoc.Open();
                    var table1 = new PdfPTable(15);
                    table1.WidthPercentage = 100;
                    table1.HorizontalAlignment = Element.ALIGN_CENTER;
                    float[] widths = new float[] { 1.2f, 3f, 1.5f, 1.5f, 2.5f, 1.5f, 1.2f, 1.5f, 2f, 1.5f, 1.5f, 1.5f, 1.5f, 1.2f, 2f };
                    table1.SetWidths(widths);
                    table1.SpacingAfter = 15;

                    iTextSharp.text.Font fntTableFont1 = new Font(Font.FontFamily.TIMES_ROMAN, 10, iTextSharp.text.Font.BOLD, BaseColor.BLACK);
                    iTextSharp.text.Font fntTableFont = new Font(Font.FontFamily.TIMES_ROMAN, 8, iTextSharp.text.Font.NORMAL, BaseColor.BLACK);
                    iTextSharp.text.Font fntTableHeading = new Font(Font.FontFamily.TIMES_ROMAN, 14, iTextSharp.text.Font.BOLD, BaseColor.MAGENTA);
                    iTextSharp.text.Font fntTableFont2 = new Font(Font.FontFamily.TIMES_ROMAN, 10, iTextSharp.text.Font.NORMAL, BaseColor.BLACK);

                    iTextSharp.text.Font georgia = FontFactory.GetFont("georgia", 16f, 1, new BaseColor(System.Drawing.Color.Red));
                    Chunk beginning = new Chunk(PayrollDate, georgia);
                    Phrase p1 = new Phrase(beginning);
                    PdfPCell CellHeading = new PdfPCell(p1);
                    CellHeading.Colspan = 15;
                    CellHeading.Border = 0;
                    CellHeading.HorizontalAlignment = Element.ALIGN_MIDDLE;
                    CellHeading.HorizontalAlignment = Element.ALIGN_CENTER;
                    table1.AddCell(CellHeading);

                    CellHeading = new PdfPCell(new Phrase(" "));
                    CellHeading.Colspan = 15;
                    CellHeading.Rowspan = 4;
                    CellHeading.Border = 0;
                    CellHeading.HorizontalAlignment = Element.ALIGN_MIDDLE;
                    CellHeading.HorizontalAlignment = Element.ALIGN_CENTER;
                    table1.AddCell(CellHeading);

                    CellHeading = new PdfPCell(new Phrase(lblTotal.Text, fntTableFont));
                    CellHeading.Colspan = 7;
                    CellHeading.Border = 0;
                    CellHeading.HorizontalAlignment = Element.ALIGN_MIDDLE;
                    CellHeading.HorizontalAlignment = Element.ALIGN_CENTER;
                    table1.AddCell(CellHeading);

                    CellHeading = new PdfPCell(new Phrase("Report generated at  " + Convert.ToDateTime(lblDate2.Text).ToString("MM/dd/yyyy hh:mm:ss tt") + " by " + Session["EmpName"].ToString().Trim(), fntTableFont));
                    CellHeading.Colspan = 8;
                    CellHeading.Border = 0;
                    CellHeading.HorizontalAlignment = Element.ALIGN_MIDDLE;
                    CellHeading.HorizontalAlignment = Element.ALIGN_CENTER;
                    table1.AddCell(CellHeading);

                    if (ddlLocation.SelectedItem.Text.ToString() == "INDG" || ddlLocation.SelectedItem.Text.ToString() == "INBH")
                    {
                        DataTable dt = GetDataTable(grdPayRollIndia);

                        PdfPCell CellZero = new PdfPCell(new Phrase("Employee Information", fntTableFont1));
                        CellZero.Colspan = 8;
                        CellZero.BorderWidthRight = 1;
                        CellZero.BackgroundColor = BaseColor.LIGHT_GRAY;
                        CellZero.HorizontalAlignment = Element.ALIGN_MIDDLE;
                        CellZero.HorizontalAlignment = Element.ALIGN_CENTER;
                        CellZero.Rowspan = 2;
                        table1.AddCell(CellZero);

                        PdfPCell CellZero2 = new PdfPCell(new Phrase("Attendance Information", fntTableFont1));
                        CellZero2.Colspan = 7;
                        CellZero2.Rowspan = 2;
                        CellZero2.Border = 0;
                        CellZero2.BackgroundColor = BaseColor.LIGHT_GRAY;
                        CellZero.HorizontalAlignment = Element.ALIGN_MIDDLE;
                        CellZero2.HorizontalAlignment = Element.ALIGN_CENTER;
                        table1.AddCell(CellZero2);

                        PdfPCell[] cel = new PdfPCell[15];
                        PdfPRow row = new PdfPRow(cel);
                        cel[0] = new PdfPCell(new Phrase("EmpID", fntTableFont1));
                        cel[1] = new PdfPCell(new Phrase("Name", fntTableFont1));
                        cel[2] = new PdfPCell(new Phrase("StartDt", fntTableFont1));
                        cel[3] = new PdfPCell(new Phrase("TermDt", fntTableFont1));
                        cel[4] = new PdfPCell(new Phrase("Department", fntTableFont1));
                        cel[5] = new PdfPCell(new Phrase("Type", fntTableFont1));
                        cel[6] = new PdfPCell(new Phrase("Location", fntTableFont1));
                        cel[7] = new PdfPCell(new Phrase("Salary", fntTableFont1));
                        cel[8] = new PdfPCell(new Phrase("Working days", fntTableFont1));
                        cel[9] = new PdfPCell(new Phrase("Attend days", fntTableFont1));
                        cel[10] = new PdfPCell(new Phrase("Used", fntTableFont1));
                        cel[11] = new PdfPCell(new Phrase("Balanced", fntTableFont1));
                        cel[12] = new PdfPCell(new Phrase("Total Salary", fntTableFont1));
                        cel[13] = new PdfPCell(new Phrase("Is New", fntTableFont1));
                        cel[14] = new PdfPCell(new Phrase("Is Changes", fntTableFont1));

                        table1.Rows.Add(row);

                        for (int i = 0; i < dt.Rows.Count; i++)
                        {
                            PdfPCell[] cell1 = new PdfPCell[15];
                            PdfPRow row1 = new PdfPRow(cell1);
                            cell1[0] = new PdfPCell(new Phrase(dt.Rows[i]["EmpID"].ToString(), fntTableFont));
                            cell1[1] = new PdfPCell(new Phrase(dt.Rows[i]["Name"].ToString(), fntTableFont));
                            cell1[2] = new PdfPCell(new Phrase(dt.Rows[i]["StartDt"].ToString(), fntTableFont));
                            cell1[3] = new PdfPCell(new Phrase(dt.Rows[i]["TermDt"].ToString(), fntTableFont));
                            cell1[4] = new PdfPCell(new Phrase(dt.Rows[i]["Dept"].ToString(), fntTableFont));
                            cell1[5] = new PdfPCell(new Phrase(dt.Rows[i]["Type"].ToString(), fntTableFont));
                            cell1[6] = new PdfPCell(new Phrase(dt.Rows[i]["Location"].ToString(), fntTableFont));
                            cell1[7] = new PdfPCell(new Phrase(dt.Rows[i]["Salary"].ToString(), fntTableFont));
                            cell1[8] = new PdfPCell(new Phrase(dt.Rows[i]["WorkingDays"].ToString(), fntTableFont));
                            cell1[9] = new PdfPCell(new Phrase(dt.Rows[i]["AttendDays"].ToString(), fntTableFont));
                            cell1[10] = new PdfPCell(new Phrase(dt.Rows[i]["PaidUsed"].ToString(), fntTableFont));
                            cell1[11] = new PdfPCell(new Phrase(dt.Rows[i]["PaidBalanced"].ToString(), fntTableFont));
                            cell1[12] = new PdfPCell(new Phrase(dt.Rows[i]["TotalPay"].ToString(), fntTableFont));
                            cell1[13] = new PdfPCell(new Phrase(dt.Rows[i]["Isnew"].ToString(), fntTableFont));
                            cell1[14] = new PdfPCell(new Phrase(dt.Rows[i]["ischanges"].ToString(), fntTableFont));

                            table1.Rows.Add(row1);
                        }
                        pdfDoc.Add(table1);
                        dt = GetNewEmpTable(grdNewEmp);
                        PdfPTable tbl2 = new PdfPTable(7);
                        tbl2.HorizontalAlignment = Element.ALIGN_LEFT;
                        tbl2.WidthPercentage = 70;
                        PdfPCell celhead = new PdfPCell(new Phrase("New employee(s) data :", fntTableFont2));
                        celhead.Colspan = 7;
                        celhead.Border = 0;
                        if (dt.Rows.Count > 0)
                        {
                            tbl2.AddCell(celhead);
                            cel = new PdfPCell[7];
                            row = new PdfPRow(cel);
                            cel[0] = new PdfPCell(new Phrase("EmpID", fntTableFont2));
                            cel[1] = new PdfPCell(new Phrase("Name", fntTableFont2));
                            cel[2] = new PdfPCell(new Phrase("Emp type", fntTableFont2));
                            cel[3] = new PdfPCell(new Phrase("Start date", fntTableFont2));
                            cel[4] = new PdfPCell(new Phrase("Date of birth", fntTableFont2));
                            cel[5] = new PdfPCell(new Phrase("Deductions", fntTableFont2));
                            cel[6] = new PdfPCell(new Phrase("Address", fntTableFont2));
                            tbl2.Rows.Add(row);

                            for (int i = 0; i < dt.Rows.Count; i++)
                            {
                                PdfPCell[] cell1 = new PdfPCell[7];
                                PdfPRow row1 = new PdfPRow(cell1);
                                cell1[0] = new PdfPCell(new Phrase(dt.Rows[i]["EmpID"].ToString(), fntTableFont2));
                                cell1[1] = new PdfPCell(new Phrase(dt.Rows[i]["Name"].ToString(), fntTableFont2));
                                cell1[2] = new PdfPCell(new Phrase(dt.Rows[i]["Emp type"].ToString(), fntTableFont2));
                                cell1[3] = new PdfPCell(new Phrase(dt.Rows[i]["Start date"].ToString(), fntTableFont2));
                                cell1[4] = new PdfPCell(new Phrase(dt.Rows[i]["Date of birth"].ToString(), fntTableFont2));
                                cell1[5] = new PdfPCell(new Phrase(dt.Rows[i]["Deductions"].ToString(), fntTableFont2));
                                cell1[6] = new PdfPCell(new Phrase(dt.Rows[i]["Address"].ToString(), fntTableFont2));
                                tbl2.Rows.Add(row1);
                            }
                            pdfDoc.Add(tbl2);
                        }

                        PdfPTable tbl3 = new PdfPTable(1);
                        tbl3.WidthPercentage = 70;
                        tbl3.SpacingBefore = 10;
                        tbl3.HorizontalAlignment = Element.ALIGN_LEFT;
                        PdfPCell pcell = new PdfPCell();
                        pcell.Border = 0;

                        PdfPCell pcelhead = new PdfPCell(new Phrase("List of Changes during this period :", fntTableFont2));
                        pcelhead.Border = 0;

                        StringWriter sw = new StringWriter();
                        HtmlTextWriter hw = new HtmlTextWriter(sw);
                        rpt1.RenderControl(hw);
                        List<IElement> htmlarraylist = HTMLWorker.ParseToList(new StringReader(sw.ToString()), null);
                        if (htmlarraylist.Count > 0)
                        {
                            tbl3.AddCell(pcelhead);
                            for (int k = 0; k < htmlarraylist.Count; k++)
                            {
                                pcell.AddElement((IElement)(htmlarraylist[k]));
                            }
                            tbl3.AddCell(pcell);
                            pdfDoc.Add(tbl3);
                        }
                        pdfDoc.Close();
                        Response.Write(pdfDoc);
                        showpdf(Session["FilePath"].ToString());
                        Response.End();
                    }
                }
                else
                {
                    var pdfDoc = new Document(new Rectangle(1200,800));
                    PdfWriter.GetInstance(pdfDoc, new FileStream(filepath + "Payroll"+CurrentDate+".pdf", FileMode.Create));
                    Session["FilePath"] = filepath + "Payroll" + CurrentDate + ".pdf";
                    Session["filename"] = "Payroll" + CurrentDate + ".pdf";
                    StringWriter sw = new StringWriter();
                    HtmlTextWriter hw = new HtmlTextWriter(sw);
                    dvpayrollreport.RenderControl(hw);
                    StringReader sr = new StringReader(sw.ToString());
                    HTMLWorker htmlparser = new HTMLWorker(pdfDoc);
                   // PdfWriter.GetInstance(pdfDoc, new FileStream(filepath + "Payroll.pdf", FileMode.Create));
                    Session["FilePath"] = filepath + "Payroll.pdf";
                    pdfDoc.Open();

                    iTextSharp.text.Font georgia = FontFactory.GetFont("georgia", 20f, 1, new BaseColor(System.Drawing.Color.Brown));
                    //georgia.Color = Color.Gray;
                    Chunk beginning = new Chunk(PayrollDate, georgia);
                    Phrase p1 = new Phrase(beginning);
                    Phrase p2 = new Phrase();
                    pdfDoc.Add(new Paragraph(p1));
                    //pdfDoc.Add(new Paragraph(30f, "Created at" + Convert.ToDateTime(lblDate2.Text).ToString("MM/dd/yyyy hh:mm:ss tt") + " by " + Session["EmpName"].ToString().Trim()));
                    //pdfDoc.AddTitle(PayrollDate);
                    htmlparser.Parse(sr);
                    pdfDoc.Close();
                    Response.Write(pdfDoc);
                    showpdf(Session["FilePath"].ToString());
                    Response.End();
                }
            }
            catch (Exception ex)
            {
            }
        }
Exemplo n.º 32
0
 /**
 * Imports a PdfPRow and copies all settings
 * 
 * @param row The PdfPRow to import
 * @since 2.1.3
 */
 private void ImportRow(PdfPRow row) {
     this.cells = new ArrayList();
     this.width = this.document.GetDocumentHeader().GetPageSetting().GetPageWidth() - this.document.GetDocumentHeader().GetPageSetting().GetMarginLeft() - this.document.GetDocumentHeader().GetPageSetting().GetMarginRight();
     this.width = (int) (this.width * this.parentTable.GetTableWidthPercent() / 100);
     
     int cellRight = 0;
     int cellWidth = 0;
     PdfPCell[] cells = row.GetCells();
     for (int i = 0; i < cells.Length; i++) {
         cellWidth = (int) (this.width * this.parentTable.GetProportionalWidths()[i] / 100);
         cellRight = cellRight + cellWidth;
         
         PdfPCell cell = cells[i];
         RtfCell rtfCell = new RtfCell(this.document, this, cell);
         rtfCell.SetCellRight(cellRight);
         rtfCell.SetCellWidth(cellWidth);
         this.cells.Add(rtfCell);
     }
 }
Exemplo n.º 33
0
        /// <summary>
        /// 创建参数表格
        /// </summary>
        /// <param name="tableEle"></param>
        /// <param name="columnCount"></param>
        protected void CreateCompareTable2(XElement tableEle, int columnCount)
        {
            string remark = tableEle.Attribute("remark").Value;
            Paragraph parTableRemark = new Paragraph(remark, fontTableRemark);
            parTableRemark.IndentationLeft = 24;
            parTableRemark.SpacingBefore = 20;
            pdfDoc.Add(parTableRemark);

            PdfPTable table = new iTextSharp.text.pdf.PdfPTable(new float[] { 270, 80, 80, 80, 80, 80, 80 });
            List<PdfPRow> rowList = new List<iTextSharp.text.pdf.PdfPRow>();
            for (int i = 0; i < tableEle.Elements().Count(); i++)
            {
                XElement rowEle = tableEle.Elements().ElementAt(i);
                List<PdfPCell> cellList = new List<iTextSharp.text.pdf.PdfPCell>();
                foreach (XElement cellEle in rowEle.Elements())
                {
                    string label = cellEle.Attribute("label").Value;
                    if (label.Trim().Equals(""))
                    {
                        label = "/";
                    }
                    if (label.Trim().Equals("-"))
                    {
                        label = "";
                    }

                    iTextSharp.text.pdf.PdfPCell cellLabel = null;
                    if (i < 1)
                    {
                        cellLabel = new iTextSharp.text.pdf.PdfPCell(new Phrase(label, fontLabel));
                        cellLabel.HorizontalAlignment = PdfPCell.ALIGN_CENTER;
                    }
                    else
                    {
                        cellLabel = new iTextSharp.text.pdf.PdfPCell(new Phrase(label, fontContent));
                        cellLabel.HorizontalAlignment = PdfPCell.ALIGN_LEFT;
                    }
                    cellLabel.FixedHeight = 24;
                    cellLabel.Padding = 4;

                    cellLabel.VerticalAlignment = PdfPCell.ALIGN_MIDDLE;

                    XAttribute colSpanAtt = cellEle.Attribute("colspan");
                    if (colSpanAtt != null)
                    {
                        string colspan = colSpanAtt.Value;
                        if (colspan != "")
                        {
                            cellLabel.Colspan = int.Parse(colspan);
                        }
                    }
                    //XAttribute rowSpanAtt = cellEle.Attribute("rowspan");
                    //if (rowSpanAtt != null)
                    //{
                    //    string rowspan = rowSpanAtt.Value;
                    //    if (rowspan != "")
                    //    {
                    //        cellLabel.Rowspan = int.Parse(rowspan);
                    //    }
                    //}

                    cellList.Add(cellLabel);
                }
                PdfPRow row = new iTextSharp.text.pdf.PdfPRow(cellList.ToArray<PdfPCell>());
                rowList.Add(row);
            }
            table.Rows.AddRange(rowList);
            //table.KeepTogether = true;
            table.SpacingBefore = 10;
            table.TotalWidth = 750;

            table.LockedWidth = true;
            Paragraph pTable = new Paragraph();
            pTable.Add(table);
            pdfDoc.Add(pTable);
        }
Exemplo n.º 34
0
        public void writeCells(float xPos, float yPos, PdfContentByte[] canvases)
        {
            if (!calculated)
            {
                calculateHeights();
            }
            for (int k = 0; k < cells.Length; ++k)
            {
                PdfPCell cell = cells[k];
                if (cell == null)
                {
                    continue;
                }
                writeBorderAndBackgroung(xPos, yPos, cell, canvases);
                PdfPTable table = cell.Table;
                float     tly   = 0;
                switch (cell.VerticalAlignment)
                {
                case Element.ALIGN_BOTTOM:
                    tly = cell.Top + yPos - maxHeight + cell.Height - cell.PaddingTop;
                    break;

                case Element.ALIGN_MIDDLE:
                    tly = cell.Top + yPos + (cell.Height - maxHeight) / 2 - cell.PaddingTop;
                    break;

                default:
                    tly = cell.Top + yPos - cell.PaddingTop;
                    break;
                }
                if (table == null)
                {
                    float fixedHeight = cell.FixedHeight;
                    float rightLimit  = cell.Right + xPos - cell.PaddingRight;
                    float leftLimit   = cell.Left + xPos + cell.PaddingLeft;
                    if (cell.isNoWrap())
                    {
                        switch (cell.HorizontalAlignment)
                        {
                        case Element.ALIGN_CENTER:
                            rightLimit += 10000;
                            leftLimit  -= 10000;
                            break;

                        case Element.ALIGN_RIGHT:
                            leftLimit -= 20000;
                            break;

                        default:
                            rightLimit += 20000;
                            break;
                        }
                    }
                    ColumnText ct  = new ColumnText(canvases[PdfPTable.TEXTCANVAS]);
                    float      bry = -20000;
                    if (fixedHeight > 0)
                    {
                        if (cell.Height > maxHeight)
                        {
                            tly = cell.Top + yPos - cell.PaddingTop;
                            bry = cell.Top + yPos - maxHeight + cell.PaddingBottom;
                        }
                    }
                    ct.setSimpleColumn(cell.Phrase,
                                       leftLimit,
                                       tly,
                                       rightLimit,
                                       bry,
                                       0, cell.HorizontalAlignment);
                    ct.setLeading(cell.Leading, cell.MultipliedLeading);
                    ct.Indent = cell.Indent;
                    ct.ExtraParagraphSpace = cell.ExtraParagraphSpace;
                    ct.FollowingIndent     = cell.FollowingIndent;
                    ct.RightIndent         = cell.RightIndent;
                    ct.SpaceCharRatio      = cell.SpaceCharRatio;
                    ct.RunDirection        = cell.RunDirection;
                    try {
                        ct.go();
                    }
                    catch (DocumentException e) {
                        throw e;
                    }
                }
                else
                {
                    float remainingHeight = 0;
                    float maxLastRow      = 0;
                    //add by Jin-Hsia Yang, to add remaining height to last row
                    if (table.Size > 0)
                    {
                        PdfPRow row = table.getRow(table.Size - 1);
                        remainingHeight = maxHeight - table.TotalHeight - cell.PaddingBottom - cell.PaddingTop;
                        if (remainingHeight > 0)
                        {
                            maxLastRow     = row.MaxHeights;
                            row.MaxHeights = row.MaxHeights + remainingHeight;
                            //table.setTotalHeight(table.TotalHeight + remainingHeight);
                        }
                    }
                    //end add

                    table.writeSelectedRows(0, -1, cell.Left + xPos + cell.PaddingLeft,
                                            tly, canvases);
                    if (remainingHeight > 0)
                    {
                        table.getRow(table.Size - 1).MaxHeights = maxLastRow;
                    }
                }
            }
        }
Exemplo n.º 35
0
        /// <summary>
        /// 创建测试者信息和测试信息表格
        /// </summary>
        /// <param name="tableEle"></param>
        /// <param name="columnCount"></param>
        protected void CreateTestInfoTable(XElement tableEle, int columnCount)
        {
            string remark = tableEle.Attribute("remark").Value;
            Paragraph parTableRemark = new Paragraph(remark, fontTableRemark);
            parTableRemark.IndentationLeft = 24;
            parTableRemark.SpacingBefore = 20;
            pdfDoc.Add(parTableRemark);

            PdfPTable table = new iTextSharp.text.pdf.PdfPTable(columnCount);
            List<PdfPRow> rowList = new List<iTextSharp.text.pdf.PdfPRow>();
            foreach (XElement rowEle in tableEle.Elements())
            {
                List<PdfPCell> cellList = new List<iTextSharp.text.pdf.PdfPCell>();
                foreach (XElement cellEle in rowEle.Elements())
                {
                    string label = cellEle.Attribute("label").Value;
                    string value = cellEle.Attribute("value").Value;
                    if (value.Trim().Equals(""))
                    {
                        value = "/";
                    }

                    iTextSharp.text.pdf.PdfPCell cellLabel = new iTextSharp.text.pdf.PdfPCell(new Phrase(label, fontLabel));
                    cellLabel.FixedHeight = 24;
                    cellLabel.Padding = 4;
                    cellLabel.HorizontalAlignment = PdfPCell.ALIGN_RIGHT;
                    cellLabel.VerticalAlignment = PdfPCell.ALIGN_MIDDLE;

                    PdfPCell cellContent = new iTextSharp.text.pdf.PdfPCell(new Phrase(value, fontContent));
                    cellContent.FixedHeight = 24;
                    cellContent.PaddingTop = 4;
                    cellContent.VerticalAlignment = PdfPCell.ALIGN_MIDDLE;
                    XAttribute colSpanAtt = cellEle.Attribute("colspan");
                    if (colSpanAtt != null)
                    {
                        string colspan = colSpanAtt.Value;
                        if (colspan != "")
                        {
                            cellContent.Colspan = int.Parse(colspan);
                        }
                    }
                    cellList.Add(cellLabel);
                    cellList.Add(cellContent);
                }
                PdfPRow row = new iTextSharp.text.pdf.PdfPRow(cellList.ToArray<PdfPCell>());
                rowList.Add(row);
            }
            table.Rows.AddRange(rowList);
            table.KeepTogether = true;
            table.SpacingBefore = 10;
            table.TotalWidth = 750;
            table.LockedWidth = true;
            Paragraph pTable = new Paragraph();
            pTable.Add(table);
            pdfDoc.Add(pTable);
        }
Exemplo n.º 36
0
 public PdfPRow(PdfPCell[] cells, PdfPRow source) {
     this.cells = cells;
     widths = new float[cells.Length];
     InitExtraHeights();
     if (source != null) {
         this.id = source.ID;
         this.role = source.Role;
         if (source.accessibleAttributes != null)
             this.accessibleAttributes = new Dictionary<PdfName, PdfObject>(source.GetAccessibleAttributes());
     }
 }
Exemplo n.º 37
0
 /**
 * Splits a row to newHeight. The returned row is the remainder. It will
 * return null if the newHeight was so small that only an empty row would
 * result.
 *
 * @param newHeight
 *            the new height
 * @return the remainder row or null if the newHeight was so small that only
 *         an empty row would result
 */
 public PdfPRow SplitRow(float newHeight)
 {
     PdfPCell[] newCells = new PdfPCell[cells.Length];
     float[] fh = new float[cells.Length * 2];
     bool allEmpty = true;
     for (int k = 0; k < cells.Length; ++k) {
         PdfPCell cell = cells[k];
         if (cell == null)
             continue;
         fh[k * 2] = cell.FixedHeight;
         fh[k * 2 + 1] = cell.MinimumHeight;
         Image img = cell.Image;
         PdfPCell c2 = new PdfPCell(cell);
         if (img != null) {
             if (newHeight > cell.EffectivePaddingBottom
                     + cell.EffectivePaddingTop + 2) {
                 c2.Phrase = null;
                 allEmpty = false;
             }
         } else {
             int status;
             float y;
             ColumnText ct = ColumnText.Duplicate(cell.Column);
             if (cell.Rotation == 90 || cell.Rotation == 270) {
                 y = SetColumn(ct,
                         cell.Top - newHeight + cell.EffectivePaddingBottom,
                         cell.Left + cell.EffectivePaddingLeft,
                         cell.Top - cell.EffectivePaddingTop,
                         cell.Right - cell.EffectivePaddingRight);
             }
             else {
                 float rightLimit = cell.NoWrap ? 20000 : cell.Right
                         - cell.EffectivePaddingRight;
                 float y1 = cell.Top - newHeight
                         + cell.EffectivePaddingBottom;
                 float y2 = cell.Top - cell.EffectivePaddingTop;
                 y = Math.Max(y1, y2);
                 y = SetColumn(ct,
                         cell.Left + cell.EffectivePaddingLeft, y1,
                         rightLimit, y2);
             }
             status = ct.Go(true);
             bool thisEmpty = (ct.YLine == y);
             if (thisEmpty)
                 ct = ColumnText.Duplicate(cell.Column);
             allEmpty = (allEmpty && thisEmpty);
             if ((status & ColumnText.NO_MORE_TEXT) == 0 || thisEmpty) {
                 c2.Column = ct;
                 ct.FilledWidth = 0;
             } else {
                 c2.Phrase = null;
             }
         }
         newCells[k] = c2;
         cell.FixedHeight = newHeight;
     }
     if (allEmpty) {
         for (int k = 0; k < cells.Length; ++k) {
             PdfPCell cell = cells[k];
             if (cell == null)
                 continue;
             float f = fh[k * 2];
             float m = fh[k * 2 + 1];
             if (f <= 0)
                 cell.MinimumHeight = m;
             else
                 cell.FixedHeight = f;
         }
         return null;
     }
     CalculateHeights();
     PdfPRow split = new PdfPRow(newCells);
     split.widths = (float[]) widths.Clone();
     split.CalculateHeights();
     return split;
 }
Exemplo n.º 38
0
 /**
 * Makes a copy of an existing row.
 *
 * @param row
 */
 public PdfPRow(PdfPRow row)
 {
     maxHeight = row.maxHeight;
     calculated = row.calculated;
     cells = new PdfPCell[row.cells.Length];
     for (int k = 0; k < cells.Length; ++k) {
         if (row.cells[k] != null)
             cells[k] = new PdfPCell(row.cells[k]);
     }
     widths = new float[cells.Length];
     System.Array.Copy(row.widths, 0, widths, 0, cells.Length);
     InitExtraHeights();
 }
Exemplo n.º 39
0
        /// <summary>
        /// 创建参数表格
        /// </summary>
        /// <param name="tableEle"></param>
        /// <param name="columnCount"></param>
        protected void CreateCompareTable2(XElement tableEle, int columnCount)
        {
            string    remark         = tableEle.Attribute("remark").Value;
            Paragraph parTableRemark = new Paragraph(remark, fontTableRemark);

            parTableRemark.IndentationLeft = 24;
            parTableRemark.SpacingBefore   = 20;
            pdfDoc.Add(parTableRemark);

            PdfPTable      table   = new iTextSharp.text.pdf.PdfPTable(new float[] { 270, 80, 80, 80, 80, 80, 80 });
            List <PdfPRow> rowList = new List <iTextSharp.text.pdf.PdfPRow>();

            for (int i = 0; i < tableEle.Elements().Count(); i++)
            {
                XElement        rowEle   = tableEle.Elements().ElementAt(i);
                List <PdfPCell> cellList = new List <iTextSharp.text.pdf.PdfPCell>();
                foreach (XElement cellEle in rowEle.Elements())
                {
                    string label = cellEle.Attribute("label").Value;
                    if (label.Trim().Equals(""))
                    {
                        label = "/";
                    }
                    if (label.Trim().Equals("-"))
                    {
                        label = "";
                    }

                    iTextSharp.text.pdf.PdfPCell cellLabel = null;
                    if (i < 1)
                    {
                        cellLabel = new iTextSharp.text.pdf.PdfPCell(new Phrase(label, fontLabel));
                        cellLabel.HorizontalAlignment = PdfPCell.ALIGN_CENTER;
                    }
                    else
                    {
                        cellLabel = new iTextSharp.text.pdf.PdfPCell(new Phrase(label, fontContent));
                        cellLabel.HorizontalAlignment = PdfPCell.ALIGN_LEFT;
                    }
                    cellLabel.FixedHeight = 24;
                    cellLabel.Padding     = 4;

                    cellLabel.VerticalAlignment = PdfPCell.ALIGN_MIDDLE;

                    XAttribute colSpanAtt = cellEle.Attribute("colspan");
                    if (colSpanAtt != null)
                    {
                        string colspan = colSpanAtt.Value;
                        if (colspan != "")
                        {
                            cellLabel.Colspan = int.Parse(colspan);
                        }
                    }
                    //XAttribute rowSpanAtt = cellEle.Attribute("rowspan");
                    //if (rowSpanAtt != null)
                    //{
                    //    string rowspan = rowSpanAtt.Value;
                    //    if (rowspan != "")
                    //    {
                    //        cellLabel.Rowspan = int.Parse(rowspan);
                    //    }
                    //}


                    cellList.Add(cellLabel);
                }
                PdfPRow row = new iTextSharp.text.pdf.PdfPRow(cellList.ToArray <PdfPCell>());
                rowList.Add(row);
            }
            table.Rows.AddRange(rowList);
            //table.KeepTogether = true;
            table.SpacingBefore = 10;
            table.TotalWidth    = 750;

            table.LockedWidth = true;
            Paragraph pTable = new Paragraph();

            pTable.Add(table);
            pdfDoc.Add(pTable);
        }
Exemplo n.º 40
0
        /**
        * Calculates the extra height needed in a row because of rowspans.
        * @param    start   the index of the start row (the one to adjust)
        * @param    end     the index of the end row on the page
        * @since    2.1.6
        */

        virtual protected PdfPRow AdjustCellsInRow(int start, int end)
        {
            PdfPRow row = GetRow(start);
            if (row.Adjusted) return row;
            row = new PdfPRow(row);
            PdfPCell cell;
            PdfPCell[] cells = row.GetCells();
            for (int i = 0; i < cells.Length; i++)
            {
                cell = cells[i];
                if (cell == null || cell.Rowspan == 1)
                    continue;
                int stop = Math.Min(end, start + cell.Rowspan);
                float extra = 0;
                for (int k = start + 1; k < stop; k++)
                {
                    extra += GetRow(k).MaxHeights;
                }
                row.SetExtraHeight(i, extra);
            }
            row.Adjusted = true;
            return row;
        }
Exemplo n.º 41
0
 private void WriteAttributes(PdfPRow row)
 {
     if (row != null)
     {
     }
 }
Exemplo n.º 42
0
        /**
        * Adds a cell element.
        * 
        * @param cell the cell element
        */

        virtual public PdfPCell AddCell(PdfPCell cell)
        {
            rowCompleted = false;
            PdfPCell ncell;
            if (cell is PdfPHeaderCell)
                ncell = new PdfPHeaderCell((PdfPHeaderCell)cell);
            else
                ncell = new PdfPCell(cell);

            int colspan = ncell.Colspan;
            colspan = Math.Max(colspan, 1);
            colspan = Math.Min(colspan, currentRow.Length - currentColIdx);
            ncell.Colspan = colspan;

            if (colspan != 1)
                isColspan = true;
            int rdir = ncell.RunDirection;
            if (rdir == PdfWriter.RUN_DIRECTION_DEFAULT)
                ncell.RunDirection = runDirection;

            SkipColsWithRowspanAbove();

            bool cellAdded = false;
            if (currentColIdx < currentRow.Length)
            {
                currentRow[currentColIdx] = ncell;
                currentColIdx += colspan;
                cellAdded = true;
            }

            SkipColsWithRowspanAbove();

            while (currentColIdx >= currentRow.Length)
            {
                int numCols = NumberOfColumns;
                if (runDirection == PdfWriter.RUN_DIRECTION_RTL)
                {
                    PdfPCell[] rtlRow = new PdfPCell[numCols];
                    int rev = currentRow.Length;
                    for (int k = 0; k < currentRow.Length; ++k)
                    {
                        PdfPCell rcell = currentRow[k];
                        int cspan = rcell.Colspan;
                        rev -= cspan;
                        rtlRow[rev] = rcell;
                        k += cspan - 1;
                    }
                    currentRow = rtlRow;
                }
                PdfPRow row = new PdfPRow(currentRow);
                if (totalWidth > 0)
                {
                    row.SetWidths(absoluteWidths);
                    totalHeight += row.MaxHeights;
                }
                rows.Add(row);
                currentRow = new PdfPCell[numCols];
                currentColIdx = 0;
                SkipColsWithRowspanAbove();
                rowCompleted = true;
            }

            if (!cellAdded)
            {
                currentRow[currentColIdx] = ncell;
                currentColIdx += colspan;
            }
            return ncell;
        }
Exemplo n.º 43
0
        private void GenPDFReport(string strGUID)
        {
            try
            {

                #region 业务逻辑处理开始

                RptBLL rptBLL = new RptBLL();
                ActivityBLL aBLL = new ActivityBLL();
                GuidBLL guidBLL = new GuidBLL();
                CommentBLL cBLL = new CommentBLL();

                DataTable dtTmp = rptBLL.GetDimensionScore(strGUID);
                dtTmp.DefaultView.Sort = "DIMCLASSID ASC";
                DataTable dimTable = dtTmp.DefaultView.ToTable();

                DataTable testerInfoTable = rptBLL.GetTesterInfo(strGUID);
                DimensionBLL dimbll = new DimensionBLL();

                //double totalMinutes = rptBLL.GetRefTotalTimeMinute(strGUID);

                double refMinMinutes = 0;
                double refMaxMinutes = 0;

                //if (totalMinutes > 12.1)
                //{
                //    refMinMinutes = totalMinutes - (double)12.1;
                //}
                //refMaxMinutes = totalMinutes + 12.1;

                refMinMinutes = rptBLL.GetRefTotalTimeMinute_xiaxian(strGUID);
                refMaxMinutes = rptBLL.GetRefTotalTimeMinute_shangxian(strGUID);

                string strREFtime = refMinMinutes.ToString("F1") + " ~ " + refMaxMinutes.ToString("F1");

                string shcxxDENGJI = string.Empty;
                string shcxxPINGDING = string.Empty;
                string shcxxMIAOSHU = string.Empty;

                string cxbxPY = string.Empty;//诚信表现评语

                string usrNm = testerInfoTable.Rows[0]["testerNAME"].ToString();
                string posNm = testerInfoTable.Rows[0]["testerPOSITION"].ToString();

                int aID = guidBLL.GetActivityId(strGUID);
                int positionId = aBLL.GetPositionId(aID);
                Activity a = aBLL.GetModel(aID);
                int rptSettings = a.Activity_viewreport;

                bool p5Visible = true;
                bool p6Visible = true;

                if (rptSettings != 0 && rptSettings.ToString().Length > 1)
                {
                    p5Visible = rptSettings.ToString().Substring(5, 1).Equals("1");
                    p6Visible = rptSettings.ToString().Substring(6, 1).Equals("1");
                }

                ArrayList arGZZT_youshi = new ArrayList();//工作状况_优势
                ArrayList arGZZT_lieshi = new ArrayList();//工作状况_劣势

                string youshi = string.Empty;
                string lieshi = string.Empty;

                bool bAllDimIsLow = false;//所有维度偏低
                bool bAllDimIsHigh = false;//所有维度偏高

                StringBuilder sbGZZT = new StringBuilder();//工作状况
                StringBuilder sbTZMS = new StringBuilder();//特质描述
                StringBuilder sbYRJY = new StringBuilder();//用人建议
                StringBuilder sbGRFZ = new StringBuilder();//个人发展

                //作答结果是否可信>>>>>>>
                bool b1 = false;//实际作答时间是否落在参考值区间
                bool b2 = false;//社会称许性等级得分大于7.9
                bool b3 = false;//作答一致性处于"较高"的等级
                //作答结果是否可信<<<<<<<

                for (int i = 0; i < dimTable.Rows.Count; i++)
                {
                    int dimID = Int32.Parse(dimTable.Rows[i][0].ToString());//维度ID
                    int dimscore = Int32.Parse(dimTable.Rows[i][2].ToString());//维度原始分
                    Double dim_s = Double.Parse(dimTable.Rows[i][3].ToString());//维度参考区间开始分
                    Double dim_e = Double.Parse(dimTable.Rows[i][4].ToString());//维度参考区间结束分

                    //Double dimQ1 = Double.Parse(dimTable.Rows[i][9].ToString());//Q1
                    //Double dimQ2 = Double.Parse(dimTable.Rows[i][10].ToString());//Q2
                    //Double dimQ3 = Double.Parse(dimTable.Rows[i][11].ToString());//Q3

                    Double p17 = Double.Parse(dimTable.Rows[i][9].ToString());
                    Double p68 = Double.Parse(dimTable.Rows[i][10].ToString());
                    Double p92 = Double.Parse(dimTable.Rows[i][11].ToString());

                    if (dimscore <= p17)
                    {
                        dimTable.Rows[i][8] = "偏低";
                    }
                    else if (dimscore > p17 && dimscore <= p68)
                    {
                        dimTable.Rows[i][8] = "稍低";
                    }
                    else if (dimscore > p68 && dimscore < p92)
                    {
                        dimTable.Rows[i][8] = "适配";
                    }
                    else if (dimscore >= p92)
                    {
                        dimTable.Rows[i][8] = "偏高";
                    }

                    //维度内判断诚信等级>>>>>>>>>>>>>>>>>>>>>>>>>>>>
                    if (dimTable.Rows[i][1].ToString().Trim().Equals("诚信"))
                    {
                        if (dimscore <= 59.5)
                        {
                            cxbxPY = "有待提高";
                        }
                        else if (dimscore >= 73.5)
                        {
                            cxbxPY = "比较诚信";
                        }
                        else if (dimscore > 59.5 && dimscore < 73.5)
                        {
                            cxbxPY = "中等";
                        }
                    }
                    //维度内判断诚信等级<<<<<<<<<<<<<<<<<<<<<<<<<<<<

                    //获取评语>>>>>>>>>>>>>>>>>>>>>>>>>>>>
                    for (int kk = 1; kk < 5; kk++)
                    {
                        if (dimTable.Rows[i][8].ToString().Trim().Equals("偏低"))
                        {
                            string c = cBLL.GetCommentByAll(positionId, dimID, kk, 4);
                            if (kk == 1)
                            {
                                if (!string.IsNullOrEmpty(c))
                                {
                                    sbTZMS.Append((i + 1).ToString() + "、" + c + Environment.NewLine);
                                }
                            }
                            else if (kk == 2)
                            {
                                if (!string.IsNullOrEmpty(c))
                                {
                                    sbGZZT.Append((i + 1).ToString() + "、" + c + Environment.NewLine);
                                    arGZZT_lieshi.Add(c + Environment.NewLine);
                                }
                            }
                            else if (kk == 3)
                            {
                                if (!string.IsNullOrEmpty(c))
                                {
                                    sbYRJY.Append("  * " + c + Environment.NewLine);
                                }
                            }
                            else if (kk == 4)
                            {
                                if (!string.IsNullOrEmpty(c))
                                {
                                    sbGRFZ.Append("  * " + c + Environment.NewLine);
                                }
                            }

                            dimTable.Rows[i][12] = cBLL.GetCommentByAll(positionId, dimID, 1, 4);
                        }
                        else if (dimTable.Rows[i][8].ToString().Trim().Equals("稍低"))
                        {
                            string c = cBLL.GetCommentByAll(positionId, dimID, kk, 3);
                            if (kk == 1)
                            {
                                if (!string.IsNullOrEmpty(c))
                                {
                                    sbTZMS.Append((i + 1).ToString() + "、" + c + Environment.NewLine);
                                }
                            }
                            else if (kk == 2)
                            {
                                if (!string.IsNullOrEmpty(c))
                                {
                                    sbGZZT.Append((i + 1).ToString() + "、" + c + Environment.NewLine);
                                    arGZZT_lieshi.Add(c + Environment.NewLine);
                                }
                            }
                            else if (kk == 3)
                            {
                                if (!string.IsNullOrEmpty(c))
                                {
                                    sbYRJY.Append("  * " + c + Environment.NewLine);
                                }
                            }
                            else if (kk == 4)
                            {
                                if (!string.IsNullOrEmpty(c))
                                {
                                    sbGRFZ.Append("  * " + c + Environment.NewLine);
                                }
                            }
                            dimTable.Rows[i][12] = cBLL.GetCommentByAll(positionId, dimID, 1, 3);
                        }
                        else if (dimTable.Rows[i][8].ToString().Trim().Equals("适配"))
                        {
                            string c = cBLL.GetCommentByAll(positionId, dimID, kk, 2);
                            if (kk == 1)
                            {
                                if (!string.IsNullOrEmpty(c))
                                {
                                    sbTZMS.Append((i + 1).ToString() + "、" + c + Environment.NewLine);
                                }
                            }
                            else if (kk == 2)
                            {
                                if (!string.IsNullOrEmpty(c))
                                {
                                    sbGZZT.Append((i + 1).ToString() + "、" + c + Environment.NewLine);
                                    arGZZT_youshi.Add(c + Environment.NewLine);
                                }
                            }
                            else if (kk == 3)
                            {
                                if (!string.IsNullOrEmpty(c))
                                {
                                    sbYRJY.Append("  * " + c + Environment.NewLine);
                                }
                            }
                            else if (kk == 4)
                            {
                                if (!string.IsNullOrEmpty(c))
                                {
                                    sbGRFZ.Append("  * " + c + Environment.NewLine);
                                }
                            }

                            dimTable.Rows[i][12] = cBLL.GetCommentByAll(positionId, dimID, 1, 2);
                        }
                        else if (dimTable.Rows[i][8].ToString().Trim().Equals("偏高"))
                        {
                            string c = cBLL.GetCommentByAll(positionId, dimID, kk, 1);
                            if (kk == 1)
                            {
                                if (!string.IsNullOrEmpty(c))
                                {
                                    sbTZMS.Append((i + 1).ToString() + "、" + c + Environment.NewLine);
                                }
                            }
                            else if (kk == 2)
                            {
                                if (!string.IsNullOrEmpty(c))
                                {
                                    sbGZZT.Append((i + 1).ToString() + "、" + c + Environment.NewLine);
                                    arGZZT_youshi.Add(c + Environment.NewLine);
                                }
                            }
                            else if (kk == 3)
                            {
                                if (!string.IsNullOrEmpty(c))
                                {
                                    sbYRJY.Append("  * " + c + Environment.NewLine);
                                }
                            }
                            else if (kk == 4)
                            {
                                if (!string.IsNullOrEmpty(c))
                                {
                                    sbGRFZ.Append("  * " + c + Environment.NewLine);
                                }
                            }
                            dimTable.Rows[i][12] = cBLL.GetCommentByAll(positionId, dimID, 1, 1);
                        }
                    }
                    //获取评语<<<<<<<<<<<<<<<<<<<<<<<<<<<<

                    //维度内判断社会称许性等级>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
                    if (dimTable.Rows[i][1].ToString().Trim().Equals("社会称许性"))
                    {
                        double score = double.Parse(dimTable.Rows[i][2].ToString());
                        if (score >= 0 && score <= 0.9)
                        {
                            shcxxDENGJI = "较高";
                            shcxxPINGDING = "倾向偏强";
                            shcxxMIAOSHU = "他(她)在本次答题时表现出较强的获取赞许的倾向,这种倾向可能是有意识的,也可能是无意识的,不能排除潜意识的影响";
                        }
                        else if (score >= 1.0 && score <= 4.0)
                        {
                            shcxxDENGJI = "中等";
                            shcxxPINGDING = "可接受";
                            shcxxMIAOSHU = "他(她)在本次答题时表现出与大多数人相似的称许性倾向";

                            //社会称许性取中间等级(社会称许性既不偏高,也不偏低时)显示比较可信,偏高偏低都需要进一步测评。
                            b2 = true;
                        }
                        else if (score >= 4.1 && score <= 16.0)
                        {
                            shcxxDENGJI = "较低";
                            shcxxPINGDING = "可接受";
                            shcxxMIAOSHU = "他(她)在本次答题中表现出较低的社会称许性倾向,通俗说,比起大多数人,他(她)有点不太在乎别人的评价,能够较客观的进行答题";
                        }
                    }

                    //维度内判断社会称许性等级<<<<<<<<<<<<<<<<<<<<<<<<<<<<

                    //原始分转化为标准分>>>>>>>>>>>>>>>>>>>>>>
                    if (dimTable.Rows[i][5].ToString().Trim().Equals("3"))//智力潜能类
                    {
                        dimTable.Rows[i][2] = rptBLL.ConvertZhiLiDimScore(dimID, dimscore);
                        dimTable.Rows[i][3] = rptBLL.ConvertZhiLiDimScore(dimID, dim_s);
                        dimTable.Rows[i][4] = rptBLL.ConvertZhiLiDimScore(dimID, dim_e);
                    }
                    else
                    {
                        dimTable.Rows[i][2] = rptBLL.ConvertDimScore(dimID, dimscore);
                        dimTable.Rows[i][3] = rptBLL.ConvertDimScore(dimID, dim_s);
                        dimTable.Rows[i][4] = rptBLL.ConvertDimScore(dimID, dim_e);
                    }
                    //原始分转化为标准分<<<<<<<<<<<<<<<<<<<<<<<<<<
                }

                //查看所有维度是否均较低 2012.3.18
                string dimRes = string.Empty;
                for (int kj = 0; kj < dimTable.Rows.Count; kj++)
                {
                    if (false == dimTable.Rows[kj]["DIMCLASSID"].ToString().Trim().Equals("3")&&
                        false == dimTable.Rows[kj]["DIMNM"].ToString().Trim().Equals("社会称许性") &&
                        false == dimTable.Rows[kj]["DIMNM"].ToString().Trim().Equals("心理健康度") &&
                        false == dimTable.Rows[kj]["DIMNM"].ToString().Trim().Equals("诚信"))//除去智力维度
                    {
                        dimRes = dimTable.Rows[kj]["DIMRESULT"].ToString().Trim();
                        if (dimRes.Equals("偏低") || dimRes.Equals("稍低"))
                        {
                            bAllDimIsLow = true;
                        }
                        else
                        {
                            bAllDimIsLow = false;
                            break;
                        }
                    }
                }

                //查看所有维度是否均较高 2012.3.18
                for (int jk = 0; jk < dimTable.Rows.Count; jk++)
                {
                    if (false == dimTable.Rows[jk]["DIMCLASSID"].ToString().Trim().Equals("3") &&
                        false == dimTable.Rows[jk]["DIMNM"].ToString().Trim().Equals("社会称许性") &&
                        false == dimTable.Rows[jk]["DIMNM"].ToString().Trim().Equals("心理健康度") &&
                        false == dimTable.Rows[jk]["DIMNM"].ToString().Trim().Equals("诚信"))//除去智力维度
                    {
                        dimRes = dimTable.Rows[jk]["DIMRESULT"].ToString().Trim();
                        if (dimRes.Equals("适配") || dimRes.Equals("偏高"))
                        {
                            bAllDimIsHigh = true;
                        }
                        else
                        {
                            bAllDimIsHigh = false;
                            break;
                        }
                    }
                }

                //工作劣势
                for (int mm = 0; mm < arGZZT_lieshi.Count; mm++)
                {
                    lieshi += "  " + (mm + 1).ToString() + "、" + arGZZT_lieshi[mm].ToString();
                }
                if (bAllDimIsHigh == true)//add by conghui 2012.3.18
                {
                    lieshi += "  " + "答题者在本次所测试的心理特征维度上得分均偏高,请注意其社会称许性得分,如果该得分在适中区间,可以认为他/她在这些特质方面的表现可以符合该岗位要求。";
                }

                //工作优势
                for (int nn = 0; nn < arGZZT_youshi.Count; nn++)
                {
                    youshi += "  " + (nn + 1).ToString() + "、" + arGZZT_youshi[nn].ToString();
                }
                if (bAllDimIsLow == true)//add by conghui 2012.3.18
                {
                    youshi += "  " + "答题者在本次所测试的各心理特征维度上的得分均偏低,他/她在这些方面的表现与岗位要求有些差距。";
                }

                //作答一致性等级,判定>>>>>>>>>>>>>>>>>>
                string trustful = string.Empty;
                string trustfulComments = string.Empty;
                int nTrustful = Int32.Parse(testerInfoTable.Rows[0][7].ToString());
                trustful = (nTrustful == 0) ? "较低" : "较高";
                trustfulComments = (nTrustful == 0) ? "他(她)答题时前后心理状态略不稳定,疲劳、环境干扰、心绪波动等均可能导致这种偏误" : "他(她)答题时心理状态基本稳定,此方面导致的测评偏误较小";
                if (trustful.Equals("较高"))
                {
                    b3 = true;
                }
                //作答一致性等级,判定<<<<<<<<<<<<<<<<<<<

                //作答时间,判定>>>>>>>>>>>>>>>>>>
                TimeSpan ts = DateTime.Parse(testerInfoTable.Rows[0][3].ToString()) -
                    DateTime.Parse(testerInfoTable.Rows[0][2].ToString());

                double nRealTime = (ts.TotalSeconds) / (double)60;

                string answerTimeComments = string.Empty;
                if (nRealTime <= refMinMinutes)
                {
                    answerTimeComments = "答题速度过快,有可能是答题过程不够认真或是其他原因,有待进一步了解";
                }
                else if (nRealTime >= refMaxMinutes)
                {
                    answerTimeComments = "答题速度偏慢,背后原因有待进一步了解";
                }
                else if (nRealTime > refMinMinutes && nRealTime < refMaxMinutes)
                {
                    b1 = true;
                    answerTimeComments = "答题速度比较适中";
                }
                else
                {
                    answerTimeComments = string.Empty;
                }
                //作答时间,判定<<<<<<<<<<<<<<<<<<<<<

                //提取智力维度,显示柱状图
                rptDataSet ds = new rptDataSet();
                for (int j = 0; j < dimTable.Rows.Count; j++)
                {
                    if (dimTable.Rows[j]["DIMCLASSID"].ToString().Trim().Equals("3"))//智力潜能类
                    {
                        ds.ZhiliDimScore.AddZhiliDimScoreRow(
                            dimTable.Rows[j]["DIMID"].ToString().Trim(),
                            dimTable.Rows[j]["DIMNM"].ToString().Trim(),
                            dimTable.Rows[j]["DIMSCORE"].ToString().Trim());
                    }
                }

                //删除智力维度在维度得分表里。
                for (int k = 0; k < dimTable.Rows.Count; k++)
                {
                    if (dimTable.Rows[k]["DIMCLASSID"].ToString().Trim().Equals("3"))//智力潜能类
                    {
                        dimTable.Rows[k].Delete();
                        dimTable.AcceptChanges();
                        k--;
                    }
                }

                //删除三个特殊维度在维度得分表里。
                for (int s = 0; s < dimTable.Rows.Count; s++)
                {
                    if (dimTable.Rows[s]["DIMNM"].ToString().Trim().Equals("社会称许性") ||
                        dimTable.Rows[s]["DIMNM"].ToString().Trim().Equals("心理健康度") ||
                        dimTable.Rows[s]["DIMNM"].ToString().Trim().Equals("诚信"))
                    {
                        dimTable.Rows[s].Delete();
                        dimTable.AcceptChanges();
                        s--;
                    }
                }

                string xljk = string.Empty;
                string xljkLevel = string.Empty;
                string xljkComnet = string.Empty;

                xljk = rptBLL.GetXljkLevelAndComments(strGUID);//获取心理健康等级和评语
                if (!string.IsNullOrEmpty(xljk))
                {
                    int n = xljk.IndexOf("-");
                    xljkLevel = xljk.Substring(0, n);
                    xljkComnet = xljk.Substring(n + 1, xljk.Length - n - 1);
                }

                bool b = false;
                if (b1 == true && b2 == true && b3 == true)
                {
                    b = true;//答题结果是否可信
                }

                //数据准备完毕!!!
                #endregion

                #region 准备生成pdf报告
                Document doc = new Document(PageSize.A4);
                PdfWriter writer = PdfWriter.GetInstance(doc, new FileStream(
                    Server.MapPath("../PDF") + "\\" + strGUID + ".pdf", FileMode.Create));
                doc.Open();
                BaseFont bf = BaseFont.CreateFont(@"C:\Windows\fonts\simsun.ttf",
                    BaseFont.IDENTITY_H, BaseFont.EMBEDDED);

                Font zhengwen_font = new Font(bf);
                Font zhengwen_title = new Font(bf, 12, Font.BOLD);
                #endregion

                #region 封面
                Paragraph ph = new Paragraph();
                ph.Alignment = Element.ALIGN_RIGHT;
                ph.Font = zhengwen_font;
                ph.Add("报告编号:" + strGUID);
                doc.Add(ph);

                //header
                Image jpeg = Image.GetInstance(Server.MapPath("../images/header.jpg"));
                jpeg.Alignment = Image.ALIGN_CENTER;
                jpeg.ScalePercent(70);
                doc.Add(jpeg);

                //first page title
                BaseFont bfHei = BaseFont.CreateFont(@"C:\WINDOWS\fonts\SIMHEI.TTF",
                    BaseFont.IDENTITY_H, BaseFont.EMBEDDED);
                Font fRptTitle = new Font(bfHei, 24, Font.BOLD);

                Paragraph phRptTitle = new Paragraph();
                phRptTitle.Alignment = Element.ALIGN_CENTER;

                phRptTitle.Font = fRptTitle;
                phRptTitle.Add(testerInfoTable.Rows[0]["testerCOMPANYNM"].ToString()
                    + Environment.NewLine);
                phRptTitle.Add("4S店" + posNm + "人才测评报告");
                phRptTitle.SetLeading(PARAGRAPH_SPACING, PARAGRAPH_SPACING);
                phRptTitle.SpacingAfter = 25;
                phRptTitle.SpacingBefore = 70;
                doc.Add(phRptTitle);

                //logo
                Image logo = Image.GetInstance(Server.MapPath("../images/logo.jpg"));
                logo.Alignment = Image.ALIGN_CENTER;
                logo.ScalePercent(70);
                doc.Add(logo);

                //姓名,日期
                Paragraph phNm = new Paragraph();
                //phNm.Alignment = Element.ALIGN_CENTER;
                phNm.Font = zhengwen_font;
                phNm.SetLeading(PARAGRAPH_SPACING, PARAGRAPH_SPACING);
                phNm.Add("姓名:" + usrNm + Environment.NewLine);
                phNm.Add("日期:" + DateTime.Parse(testerInfoTable.Rows[0]["testerDATE"].ToString()).ToShortDateString());
                phNm.IndentationLeft = 222;

                phNm.SpacingBefore = 100;
                phNm.SpacingAfter = 75;
                doc.Add(phNm);

                //footer
                doc.Add(jpeg);
                #endregion

                #region 报告阅读说明
                doc.NewPage();
                Paragraph p0 = new Paragraph("报告阅读说明", new Font(bfHei, 14, Font.BOLD));
                p0.SetLeading(PARAGRAPH_SPACING, PARAGRAPH_SPACING);
                p0.SpacingAfter = TITLE_TEXT_DISTANCE;//标题与后面文字间隔
                p0.Alignment = Element.ALIGN_CENTER;
                doc.Add(p0);

                Paragraph phshuoming = new Paragraph();
                phshuoming.Font = zhengwen_font;
                phshuoming.SetLeading(PARAGRAPH_SPACING, PARAGRAPH_SPACING);
                phshuoming.Alignment = Element.ALIGN_LEFT;
                phshuoming.Add(@"    本报告的系统平台内包含人格量表、态度量表、动机量表等数十种心理测验量表,开发过程综合了麦克莱兰德(David C.McClelland)、班杜拉(Albert Bandura)、卡特尔(R.B.Cattell)、吉尔福特(J.P.Guilford)、霍兰德(J.L.Holland) 等多位知名心理学家关于人格类型、态度的形成与改变、驱力理论、管理心理理论等多个专题领域的相关观点,在国内高校本土化研究实践的基础上,进一步实现汽车行业化,力争满足汽车行业广大测评使用者的需求。
             报告第一部分为本次测评有效性技术指标的监测结果,并给出简要解释,供报告使用者参考;需要说明的是,以下因素可能影响测评报告的有效性:
              * 答题者不具备基本水平的阅读理解能力
              * 答题时过于关心得到的结果是怎样的
              * 答题者误解了测评活动的本质
              * 答题者感到较大的环境压力
              * 答题过程中存在较严重的心理干扰
              * 答题者存在较强的药物依赖
             报告第二部分中综合适配度是指以本次测评报告中呈现的各心理特征维度为该岗位的胜任要求时答题者与岗位要求间的适配程度,由于不同用户定制不同,适配度含义会有差异;
             报告第三部分逐一分析各项心理特征具体水平状况,提供个人结果与参照标准的对比;
             报告第四部分管理用人建议由具备丰富汽车行业实战经验及深厚行业理论基础的资深专家二十余名参与开发,其中融入了多年实践与研究的心得,旨在帮助管理者和报告使用者明确提升方向,解决实际问题;
             报告第五部分中的个人发展建议依据杜布(L.W.Doob)、费斯汀格(L.Festinger)、科尔曼(H.Kelman)等人的相关理论编制;由于每个人职业发展机遇、所处团队文化等诸多外因的不确定性,该部分仅就本次测评结果为使用者提供个人发展方面的指导与建议。
             由于个体心理结构的复杂性、心理发展的动态性和测评条件的局限性,报告使用者需避免用绝对化的眼光看待测评报告的结果;使用本报告时若能结合标准化面试、情景模拟等其他人才测评技术手段,将会有利于进一步全面评估被测评者的个人能力。");
                doc.Add(phshuoming);
                #endregion

                #region 第一部分
                doc.NewPage();
                Paragraph p1 = new Paragraph("第一部分 测评有效性及个人基本情况", new Font(bfHei, 14, Font.BOLD));
                p1.SpacingAfter = TITLE_TEXT_DISTANCE;//标题与后面文字间隔
                p1.Alignment = Element.ALIGN_CENTER;
                doc.Add(p1);

                Paragraph p11 = new Paragraph("    本部分通过以下指标结果来综合评价本次测评的有效性,并报告答题者的基本心理状况。", zhengwen_font);
                p11.SetLeading(PARAGRAPH_SPACING, PARAGRAPH_SPACING);
                doc.Add(p11);

                //第一部分表格
                PdfPTable p1t1 = new PdfPTable(4);
                p1t1.SpacingAfter = 5;
                p1t1.SpacingBefore = 15;

                //row 1
                PdfPCell cell11 = new PdfPCell(new Paragraph("社会称许性等级", new Font(bf, 10, Font.NORMAL)));
                cell11.BackgroundColor = new BaseColor(220, 220, 220);
                cell11.BorderWidthLeft = 0;
                cell11.BorderWidthRight = 0;
                cell11.MinimumHeight = TABLE_ROW_HEIGHT;
                cell11.VerticalAlignment = Element.ALIGN_MIDDLE;
                cell11.BorderWidthBottom = 0;

                PdfPCell cell12 = new PdfPCell(new Paragraph(shcxxDENGJI, new Font(bf, 10, Font.NORMAL)));
                cell12.BorderWidthLeft = 0;
                cell12.BorderWidthRight = 0;
                cell12.VerticalAlignment = Element.ALIGN_MIDDLE;
                cell12.BorderWidthBottom = 0;

                PdfPCell cell13 = new PdfPCell(new Paragraph("社会称许性评定", new Font(bf, 10, Font.NORMAL)));
                cell13.BackgroundColor = new BaseColor(220, 220, 220);
                cell13.BorderWidthLeft = 0;
                cell13.BorderWidthRight = 0;
                cell13.VerticalAlignment = Element.ALIGN_MIDDLE;
                cell13.BorderWidthBottom = 0;

                PdfPCell cell14 = new PdfPCell(new Paragraph(shcxxPINGDING, new Font(bf, 10, Font.NORMAL)));
                cell14.BorderWidthLeft = 0;
                cell14.BorderWidthRight = 0;
                cell14.VerticalAlignment = Element.ALIGN_MIDDLE;
                cell14.BorderWidthBottom = 0;

                //row 2
                PdfPCell cell21 = new PdfPCell(new Paragraph("作答一致性等级", new Font(bf, 10, Font.NORMAL)));
                cell21.BackgroundColor = new BaseColor(220, 220, 220);
                cell21.BorderWidthLeft = 0;
                cell21.BorderWidthRight = 0;
                cell21.MinimumHeight = TABLE_ROW_HEIGHT;
                cell21.VerticalAlignment = Element.ALIGN_MIDDLE;
                cell21.BorderWidthBottom = 0;

                PdfPCell cell22 = new PdfPCell(new Paragraph(trustful, new Font(bf, 10, Font.NORMAL)));
                cell22.BorderWidthLeft = 0;
                cell22.BorderWidthRight = 0;
                cell22.VerticalAlignment = Element.ALIGN_MIDDLE;
                cell22.BorderWidthBottom = 0;

                PdfPCell cell23 = new PdfPCell(new Paragraph("测评工具信度", new Font(bf, 10, Font.NORMAL)));
                cell23.BackgroundColor = new BaseColor(220, 220, 220);
                cell23.BorderWidthLeft = 0;
                cell23.BorderWidthRight = 0;
                cell23.VerticalAlignment = Element.ALIGN_MIDDLE;
                cell23.BorderWidthBottom = 0;

                PdfPCell cell24 = new PdfPCell(new Paragraph("0.857 ~ 0.949", new Font(bf, 10, Font.NORMAL)));
                cell24.BorderWidthLeft = 0;
                cell24.BorderWidthRight = 0;
                cell24.VerticalAlignment = Element.ALIGN_MIDDLE;
                cell24.BorderWidthBottom = 0;

                //row 3
                PdfPCell cell31 = new PdfPCell(new Paragraph("作答实际时间", new Font(bf, 10, Font.NORMAL)));
                cell31.BackgroundColor = new BaseColor(220, 220, 220);
                cell31.BorderWidthLeft = 0;
                cell31.BorderWidthRight = 0;
                cell31.MinimumHeight = TABLE_ROW_HEIGHT;
                cell31.VerticalAlignment = Element.ALIGN_MIDDLE;
                cell31.BorderWidthBottom = 0;

                PdfPCell cell32 = new PdfPCell(new Paragraph(((int)ts.TotalMinutes).ToString() + "分钟", new Font(bf, 10, Font.NORMAL)));
                cell32.BorderWidthLeft = 0;
                cell32.BorderWidthRight = 0;
                cell32.VerticalAlignment = Element.ALIGN_MIDDLE;
                cell32.BorderWidthBottom = 0;

                PdfPCell cell33 = new PdfPCell(new Paragraph("答题时间参照值", new Font(bf, 10, Font.NORMAL)));
                cell33.BackgroundColor = new BaseColor(220, 220, 220);
                cell33.BorderWidthLeft = 0;
                cell33.BorderWidthRight = 0;
                cell33.VerticalAlignment = Element.ALIGN_MIDDLE;
                cell33.BorderWidthBottom = 0;

                PdfPCell cell34 = new PdfPCell(new Paragraph(strREFtime + "分钟", new Font(bf, 10, Font.NORMAL)));
                cell34.BorderWidthLeft = 0;
                cell34.BorderWidthRight = 0;
                cell34.VerticalAlignment = Element.ALIGN_MIDDLE;
                cell34.BorderWidthBottom = 0;

                //row 4
                PdfPCell cell41 = new PdfPCell(new Paragraph("答题诚信表现", new Font(bf, 10, Font.NORMAL)));
                cell41.BackgroundColor = new BaseColor(220, 220, 220);
                cell41.BorderWidthLeft = 0;
                cell41.BorderWidthRight = 0;
                cell41.MinimumHeight = TABLE_ROW_HEIGHT;
                cell41.VerticalAlignment = Element.ALIGN_MIDDLE;

                PdfPCell cell42 = new PdfPCell(new Paragraph(cxbxPY, new Font(bf, 10, Font.NORMAL)));
                cell42.BorderWidthLeft = 0;
                cell42.BorderWidthRight = 0;
                cell42.VerticalAlignment = Element.ALIGN_MIDDLE;

                PdfPCell cell43 = new PdfPCell(new Paragraph("心理健康度状况", new Font(bf, 10, Font.NORMAL)));
                cell43.BackgroundColor = new BaseColor(220, 220, 220);
                cell43.BorderWidthLeft = 0;
                cell43.BorderWidthRight = 0;
                cell43.VerticalAlignment = Element.ALIGN_MIDDLE;

                PdfPCell cell44 = new PdfPCell(new Paragraph(xljkLevel, new Font(bf, 10, Font.NORMAL)));
                cell44.BorderWidthLeft = 0;
                cell44.BorderWidthRight = 0;
                cell44.VerticalAlignment = Element.ALIGN_MIDDLE;

                PdfPCell[] cells1 = new PdfPCell[] { cell11, cell12, cell13, cell14 };
                PdfPRow row1 = new PdfPRow(cells1);
                PdfPCell[] cells2 = new PdfPCell[] { cell21, cell22, cell23, cell24 };
                PdfPRow row2 = new PdfPRow(cells2);
                PdfPCell[] cells3 = new PdfPCell[] { cell31, cell32, cell33, cell34 };
                PdfPRow row3 = new PdfPRow(cells3);
                PdfPCell[] cells4 = new PdfPCell[] { cell41, cell42, cell43, cell44 };
                PdfPRow row4 = new PdfPRow(cells4);

                p1t1.Rows.Add(row1);
                p1t1.Rows.Add(row2);
                p1t1.Rows.Add(row3);
                p1t1.Rows.Add(row4);

                doc.Add(p1t1);

                Paragraph p12 = new Paragraph("    综合来看," + usrNm + "本次作答结果" +
                    (b == true ? "比较可信。" : "有必要进一步测评。"), zhengwen_font);
                p12.SetLeading(PARAGRAPH_SPACING, PARAGRAPH_SPACING);
                doc.Add(p12);

                Paragraph p13 = new Paragraph("    1、" + shcxxMIAOSHU + ";", zhengwen_font);
                p13.SetLeading(PARAGRAPH_SPACING, PARAGRAPH_SPACING);
                doc.Add(p13);

                Paragraph p14 = new Paragraph("    2、" + trustfulComments + ";", zhengwen_font);
                p14.SetLeading(PARAGRAPH_SPACING, PARAGRAPH_SPACING);
                doc.Add(p14);

                Paragraph p15 = new Paragraph("    3、" + answerTimeComments + ";", zhengwen_font);
                p15.SetLeading(PARAGRAPH_SPACING, PARAGRAPH_SPACING);
                doc.Add(p15);

                Paragraph p16 = new Paragraph("    4、" + xljkComnet + "。", zhengwen_font);
                p16.SetLeading(PARAGRAPH_SPACING, PARAGRAPH_SPACING);
                doc.Add(p16);

                #endregion

                #region 第二部分
                doc.NewPage();
                Paragraph p2 = new Paragraph("第二部分 与4S店" + posNm + "岗位规范的综合适配情况", new Font(bfHei, 14, Font.BOLD));
                p2.SpacingAfter = TITLE_TEXT_DISTANCE;//标题与后面文字间隔
                p2.Alignment = Element.ALIGN_CENTER;
                doc.Add(p2);

                Paragraph p21 = new Paragraph("    将本次测评数据比照汽车行业该岗位素质特征模型统计数据," +
                    usrNm + "与4S店" + posNm + "的综合适配度为:", zhengwen_font);
                p21.SetLeading(PARAGRAPH_SPACING, PARAGRAPH_SPACING);
                doc.Add(p21);

                System.Drawing.Bitmap bmpScore = new System.Drawing.Bitmap(Server.MapPath(@"../images/score_bk.png"));
                System.Drawing.Graphics g = System.Drawing.Graphics.FromImage(bmpScore);
                System.Drawing.Pen redPen = new System.Drawing.Pen(System.Drawing.Color.Red, 3);
                System.Drawing.Font f = new System.Drawing.Font("Arial", 15);
                System.Drawing.SolidBrush brush = new System.Drawing.SolidBrush(System.Drawing.Color.Red);
                g.DrawString(float.Parse(testerInfoTable.Rows[0]["testerTOTALSCORE"].ToString()).ToString("0.0%"), f, brush, 18, 10);
                g.Dispose();

                Image scorePic = Image.GetInstance(bmpScore, new BaseColor(0));
                scorePic.Alignment = Image.ALIGN_CENTER;
                scorePic.ScalePercent(70);
                doc.Add(scorePic);

                Paragraph p22 = new Paragraph("    ● " + usrNm + "担任" + posNm + "的优势:", zhengwen_title);
                p22.SetLeading(PARAGRAPH_SPACING, PARAGRAPH_SPACING);
                doc.Add(p22);

                Paragraph p23 = new Paragraph("    我们对成功的建议是:“以已之长,补已之短”。学会了这一点将会影响个人对工作的喜好甚至职业发展的成败。"
                    + Environment.NewLine + youshi, zhengwen_font);
                p23.SetLeading(PARAGRAPH_SPACING, PARAGRAPH_SPACING);
                doc.Add(p23);

                Paragraph p24 = new Paragraph("    ● " + usrNm + "担任" + posNm + "的劣势:", zhengwen_title);
                p24.SetLeading(PARAGRAPH_SPACING, PARAGRAPH_SPACING);
                doc.Add(p24);

                Paragraph p25 = new Paragraph("    有的人不足之处比较明显,有的却没有明显缺点,或者他(她)自己并不容易意识到,了解个人存在的问题就是完善自我的重要一步。下面列出了他(她)工作中可能存在的欠缺,目的是为了引起对它们的 “注意”,促进反思。"
                    + Environment.NewLine + lieshi, zhengwen_font);
                p25.SetLeading(PARAGRAPH_SPACING, PARAGRAPH_SPACING);
                doc.Add(p25);

                #endregion

                #region 第三部分
                doc.NewPage();
                Paragraph p3 = new Paragraph("第三部分 各项特征具体状况", new Font(bfHei, 14, Font.BOLD));
                p3.SpacingAfter = TITLE_TEXT_DISTANCE;//标题与后面文字间隔
                p3.Alignment = Element.ALIGN_CENTER;
                doc.Add(p3);

                Paragraph p31 = new Paragraph("    下列图中灰色区间是经过统计分析得出的标准参照区间,下方红色游标指示"
                + usrNm + "在该特征上的个人得分水平。", zhengwen_font);
                p31.SetLeading(PARAGRAPH_SPACING, PARAGRAPH_SPACING);
                doc.Add(p31);

                for (int i = 0; i < dimTable.Rows.Count; i++)
                {
                    Paragraph p = new Paragraph("    " + dimTable.Rows[i]["DIMNM"].ToString(), zhengwen_title);
                    p.SetLeading(PARAGRAPH_SPACING, PARAGRAPH_SPACING);
                    doc.Add(p);

                    Double rangeStart = Double.Parse(dimTable.Rows[i]["DIMRANGE_START"].ToString());
                    Double rangeEnd = Double.Parse(dimTable.Rows[i]["DIMRANGE_END"].ToString());
                    Double rangeCurrent = Double.Parse(dimTable.Rows[i]["DIMSCORE"].ToString());

                    Image ruler = Image.GetInstance(drawRuler(rangeStart, rangeEnd, rangeCurrent), new BaseColor(0));
                    ruler.Alignment = Image.ALIGN_CENTER;
                    ruler.ScalePercent(70);
                    doc.Add(ruler);
                }

                for (int j = 0; j < dimTable.Rows.Count; j++)
                {
                    Paragraph p = new Paragraph("    ● " + dimTable.Rows[j]["DIMNM"].ToString() +
                    "  " + dimTable.Rows[j]["dimDESC"].ToString(), zhengwen_font);
                    p.SetLeading(PARAGRAPH_SPACING, PARAGRAPH_SPACING);
                    doc.Add(p);

                    Paragraph q = new Paragraph("  他(她)在这方面的表现情况是 " +
                        dimTable.Rows[j]["dimCOMMENTS"].ToString(), zhengwen_font);
                    q.SetLeading(PARAGRAPH_SPACING, PARAGRAPH_SPACING);
                    doc.Add(q);
                }

                //各项个人特征得分等级表
                Paragraph p32 = new Paragraph("各项个人特征得分等级表", zhengwen_title);
                p32.Alignment = Element.ALIGN_CENTER;
                p32.SetLeading(PARAGRAPH_SPACING, PARAGRAPH_SPACING);
                doc.Add(p32);

                PdfPTable p3t1 = new PdfPTable(4);
                p3t1.SpacingAfter = 5;
                p3t1.SpacingBefore = 15;

                /*
                //row 1
                PdfPCell c11 = new PdfPCell(new Paragraph("职业特质类别", new Font(bf, 10, Font.BOLD)));
                c11.BackgroundColor = new BaseColor(220,220,220);
                c11.BorderWidthLeft = 0;
                c11.BorderWidthRight = 0;
                c11.MinimumHeight = TABLE_ROW_HEIGHT;
                c11.VerticalAlignment = Element.ALIGN_MIDDLE;
                c11.HorizontalAlignment = Element.ALIGN_CENTER;
                c11.BorderWidthBottom = 0;
                c11.BorderWidthTop = 0;
                */

                PdfPCell c12 = new PdfPCell(new Paragraph("个人特征", new Font(bf, 10, Font.BOLD)));
                c12.BackgroundColor = new BaseColor(220, 220, 220);
                c12.BorderWidthLeft = 0;
                c12.BorderWidthRight = 0;
                c12.VerticalAlignment = Element.ALIGN_MIDDLE;
                c12.HorizontalAlignment = Element.ALIGN_CENTER;
                c12.BorderWidthBottom = 0;
                c12.BorderWidthTop = 0;
                c12.MinimumHeight = TABLE_ROW_HEIGHT;

                PdfPCell c13 = new PdfPCell(new Paragraph("实际得分", new Font(bf, 10, Font.BOLD)));
                c13.BackgroundColor = new BaseColor(220, 220, 220);
                c13.BorderWidthLeft = 0;
                c13.BorderWidthRight = 0;
                c13.VerticalAlignment = Element.ALIGN_MIDDLE;
                c13.HorizontalAlignment = Element.ALIGN_CENTER;
                c13.BorderWidthBottom = 0;
                c13.BorderWidthTop = 0;

                PdfPCell c14 = new PdfPCell(new Paragraph("参考区间", new Font(bf, 10, Font.BOLD)));
                c14.BackgroundColor = new BaseColor(220, 220, 220);
                c14.BorderWidthLeft = 0;
                c14.BorderWidthRight = 0;
                c14.VerticalAlignment = Element.ALIGN_MIDDLE;
                c14.HorizontalAlignment = Element.ALIGN_CENTER;
                c14.BorderWidthBottom = 0;
                c14.BorderWidthTop = 0;

                PdfPCell c15 = new PdfPCell(new Paragraph("评价等级", new Font(bf, 10, Font.BOLD)));
                c15.BackgroundColor = new BaseColor(220, 220, 220);
                c15.BorderWidthLeft = 0;
                c15.BorderWidthRight = 0;
                c15.VerticalAlignment = Element.ALIGN_MIDDLE;
                c15.HorizontalAlignment = Element.ALIGN_CENTER;
                c15.BorderWidthBottom = 0;
                c15.BorderWidthTop = 0;

                PdfPCell[] cs1 = new PdfPCell[] { c12, c13, c14, c15 };
                PdfPRow r1 = new PdfPRow(cs1);
                p3t1.Rows.Add(r1);

                for (int k = 0; k < dimTable.Rows.Count; k++)
                {
                    /*
                    PdfPCell c1 = new PdfPCell(new Paragraph(dimTable.Rows[k]["dimCLASSNM"].ToString(), new Font(bf, 10, Font.NORMAL)));
                    c1.VerticalAlignment = Element.ALIGN_MIDDLE;
                    c1.HorizontalAlignment = Element.ALIGN_CENTER;
                    c1.BorderWidthLeft = 0;
                    c1.BorderWidthRight = 0;
                    //c1.BorderWidthBottom = 0;
                    c1.BorderWidthTop = 0;
                    c1.MinimumHeight = TABLE_ROW_HEIGHT;
                     */

                    PdfPCell c2 = new PdfPCell(new Paragraph(dimTable.Rows[k]["dimNM"].ToString(), new Font(bf, 10, Font.NORMAL)));
                    c2.VerticalAlignment = Element.ALIGN_MIDDLE;
                    c2.HorizontalAlignment = Element.ALIGN_CENTER;
                    c2.BorderWidthLeft = 0;
                    c2.BorderWidthRight = 0;
                    //c2.BorderWidthBottom = 0;
                    c2.BorderWidthTop = 0;
                    c2.MinimumHeight = TABLE_ROW_HEIGHT;

                    PdfPCell c3 = new PdfPCell(new Paragraph(dimTable.Rows[k]["dimSCORE"].ToString(), new Font(bf, 10, Font.NORMAL)));
                    c3.VerticalAlignment = Element.ALIGN_MIDDLE;
                    c3.HorizontalAlignment = Element.ALIGN_CENTER;
                    c3.BorderWidthLeft = 0;
                    c3.BorderWidthRight = 0;
                    //c3.BorderWidthBottom = 0;
                    c3.BorderWidthTop = 0;
                    PdfPCell c4 = new PdfPCell(new Paragraph(dimTable.Rows[k]["dimRANGE_START"].ToString() + " ~ " + dimTable.Rows[k]["dimRANGE_END"].ToString(), new Font(bf, 10, Font.NORMAL)));

                    c4.VerticalAlignment = Element.ALIGN_MIDDLE;
                    c4.HorizontalAlignment = Element.ALIGN_CENTER;
                    c4.BorderWidthLeft = 0;
                    c4.BorderWidthRight = 0;
                    //c4.BorderWidthBottom = 0;
                    c4.BorderWidthTop = 0;

                    PdfPCell c5 = new PdfPCell(new Paragraph(dimTable.Rows[k]["dimRESULT"].ToString(), new Font(bf, 10, Font.NORMAL)));
                    c5.VerticalAlignment = Element.ALIGN_MIDDLE;
                    c5.HorizontalAlignment = Element.ALIGN_CENTER;
                    c5.BorderWidthLeft = 0;
                    c5.BorderWidthRight = 0;
                    //c5.BorderWidthBottom = 0;
                    c5.BorderWidthTop = 0;

                    PdfPCell[] ces1 = new PdfPCell[] { c2, c3, c4, c5 };
                    PdfPRow ro1 = new PdfPRow(ces1);
                    p3t1.Rows.Add(ro1);
                }

                doc.Add(p3t1);

                //智力柱状图

                //各项个人特征得分等级表
                if (ds != null && ds.ZhiliDimScore.Rows.Count > 0)
                {
                    Paragraph p33 = new Paragraph("各项智力测评结果图", zhengwen_title);
                    p33.Alignment = Element.ALIGN_CENTER;
                    p33.SetLeading(PARAGRAPH_SPACING, PARAGRAPH_SPACING);
                    doc.Add(p33);

                    Image chrt = Image.GetInstance(makeChart(ds.ZhiliDimScore), new BaseColor(0));
                    chrt.Alignment = Image.ALIGN_CENTER;
                    chrt.ScalePercent(80);
                    doc.Add(chrt);
                }

                #endregion

                #region 第四部分
                doc.NewPage();
                Paragraph p4 = new Paragraph("第四部分 4S店管理用人建议", new Font(bfHei, 14, Font.BOLD));
                p4.SpacingAfter = TITLE_TEXT_DISTANCE;//标题与后面文字间隔
                p4.Alignment = Element.ALIGN_CENTER;
                doc.Add(p4);

                Paragraph p41 = new Paragraph("    针对" + usrNm +
                   "的特点,管理工作中建议注意以下方面:" + Environment.NewLine + sbYRJY.ToString(), zhengwen_font);
                p41.SetLeading(PARAGRAPH_SPACING, PARAGRAPH_SPACING);
                doc.Add(p41);
                #endregion

                #region 第五部分
                doc.NewPage();
                Paragraph p5 = new Paragraph("第五部分 个人发展建议", new Font(bfHei, 14, Font.BOLD));
                p5.SpacingAfter = TITLE_TEXT_DISTANCE;//标题与后面文字间隔
                p5.Alignment = Element.ALIGN_CENTER;
                doc.Add(p5);

                Paragraph p51 = new Paragraph("    本部分是针对" + usrNm +
                    "不够完善的素质提供的一些发展建议。若能要花时间认真思考并付注于行动,定会对本人有所帮助,建议如下: " +
                    Environment.NewLine + sbGRFZ.ToString(), zhengwen_font);
                p51.SetLeading(PARAGRAPH_SPACING, PARAGRAPH_SPACING);
                doc.Add(p51);
                #endregion

                doc.Close();
            }
            catch (Exception ex)
            {
                //Response.Write(ex.Message);
                StreamWriter errof = new StreamWriter(Server.MapPath(@"../PDF/") +  "测评系统log.txt");
                errof.WriteLine(System.DateTime.Now.ToString() + ":错误: " + ex.Message);
                errof.Flush();
                errof.Close();
            }
        }