當前位置: 首頁>>代碼示例>>C#>>正文


C# PdfPCell.HasBorders方法代碼示例

本文整理匯總了C#中iTextSharp.text.pdf.PdfPCell.HasBorders方法的典型用法代碼示例。如果您正苦於以下問題:C# PdfPCell.HasBorders方法的具體用法?C# PdfPCell.HasBorders怎麽用?C# PdfPCell.HasBorders使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在iTextSharp.text.pdf.PdfPCell的用法示例。


在下文中一共展示了PdfPCell.HasBorders方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: WriteBorderAndBackground

        /**
        * Writes the border and background of one cell in the row.
        *
        * @param xPos The x-coordinate where the table starts on the canvas
        * @param yPos The y-coordinate where the table starts on the canvas
        * @param currentMaxHeight The height of the cell to be drawn.
        * @param cell
        * @param canvases
        * @since    2.1.6   extra parameter currentMaxHeight
        */
        public void WriteBorderAndBackground(float xPos, float yPos, float currentMaxHeight, PdfPCell cell, PdfContentByte[] canvases)
        {
            BaseColor background = cell.BackgroundColor;
            if (background != null || cell.HasBorders()) {
                // Add xPos resp. yPos to the cell's coordinates for absolute coordinates
                float right = cell.Right + xPos;
                float top = cell.Top + yPos;
                float left = cell.Left + xPos;
                float bottom = top - currentMaxHeight;

                if (background != null) {
                    PdfContentByte backgr = canvases[PdfPTable.BACKGROUNDCANVAS];
                    backgr.SetColorFill(background);
                    backgr.Rectangle(left, bottom, right - left, top - bottom);
                    backgr.Fill();
                }
                if (cell.HasBorders()) {
                    Rectangle newRect = new Rectangle(left, bottom, right, top);
                    // Clone non-position parameters except for the background color
                    newRect.CloneNonPositionParameters(cell);
                    newRect.BackgroundColor = null;
                    // Write the borders on the line canvas
                    PdfContentByte lineCanvas = canvases[PdfPTable.LINECANVAS];
                    lineCanvas.Rectangle(newRect);
                }
            }
        }
開發者ID:boecko,項目名稱:iTextSharp,代碼行數:37,代碼來源:PdfPRow.cs

示例2: WriteBorderAndBackground

        /**
        * Writes the border and background of one cell in the row.
        * @param xPos
        * @param yPos
        * @param cell
        * @param canvases
        */
        public void WriteBorderAndBackground(float xPos, float yPos, PdfPCell cell,
                PdfContentByte[] canvases)
        {
            PdfContentByte lines = canvases[PdfPTable.LINECANVAS];
            PdfContentByte backgr = canvases[PdfPTable.BACKGROUNDCANVAS];
            // the coordinates of the border are retrieved
            float x1 = cell.Left + xPos;
            float y2 = cell.Top + yPos;
            float x2 = cell.Right + xPos;
            float y1 = y2 - maxHeight;

            // the backgroundcolor is set
            Color background = cell.BackgroundColor;
            if (background != null) {
                backgr.SetColorFill(background);
                backgr.Rectangle(x1, y1, x2 - x1, y2 - y1);
                backgr.Fill();
            }
            // if the element hasn't got any borders, nothing is added
            if (cell.HasBorders()) {
                if (cell.UseVariableBorders) {
                    Rectangle borderRect = new Rectangle(cell.Left + xPos, cell.Top
                            - maxHeight + yPos, cell.Right + xPos, cell.Top
                            + yPos);
                    borderRect.CloneNonPositionParameters(cell);
                    borderRect.BackgroundColor = null;
                    lines.Rectangle(borderRect);
                } else {
                    // the width is set to the width of the element
                    if (cell.BorderWidth != Rectangle.UNDEFINED) {
                        lines.SetLineWidth(cell.BorderWidth);
                    }
                    // the color is set to the color of the element
                    Color color = cell.BorderColor;
                    if (color != null) {
                        lines.SetColorStroke(color);
                    }

                    // if the box is a rectangle, it is added as a rectangle
                    if (cell.HasBorder(Rectangle.BOX)) {
                        lines.Rectangle(x1, y1, x2 - x1, y2 - y1);
                    }
                    // if the border isn't a rectangle, the different sides are
                    // added apart
                    else {
                        if (cell.HasBorder(Rectangle.RIGHT_BORDER)) {
                            lines.MoveTo(x2, y1);
                            lines.LineTo(x2, y2);
                        }
                        if (cell.HasBorder(Rectangle.LEFT_BORDER)) {
                            lines.MoveTo(x1, y1);
                            lines.LineTo(x1, y2);
                        }
                        if (cell.HasBorder(Rectangle.BOTTOM_BORDER)) {
                            lines.MoveTo(x1, y1);
                            lines.LineTo(x2, y1);
                        }
                        if (cell.HasBorder(Rectangle.TOP_BORDER)) {
                            lines.MoveTo(x1, y2);
                            lines.LineTo(x2, y2);
                        }
                    }
                    lines.Stroke();
                    if (color != null) {
                        lines.ResetRGBColorStroke();
                    }
                }
            }
        }
開發者ID:hjgode,項目名稱:iTextSharpCF,代碼行數:76,代碼來源:PdfPRow.cs


注:本文中的iTextSharp.text.pdf.PdfPCell.HasBorders方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。