当前位置: 首页>>代码示例>>C#>>正文


C# Rectangle.GetRectangle方法代码示例

本文整理汇总了C#中iTextSharp.text.Rectangle.GetRectangle方法的典型用法代码示例。如果您正苦于以下问题:C# Rectangle.GetRectangle方法的具体用法?C# Rectangle.GetRectangle怎么用?C# Rectangle.GetRectangle使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在iTextSharp.text.Rectangle的用法示例。


在下文中一共展示了Rectangle.GetRectangle方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: AddPdfTable

        /**
        * Adds a new table to
        * @param table              Table to add.  Rendered rows will be deleted after processing.
        * @param onlyFirstPage      Render only the first full page
        * @throws DocumentException
        */
        private void AddPdfTable(Table t)
        {
            // before every table, we flush all lines
            FlushLines();

            PdfTable table = new PdfTable(t, IndentLeft, IndentRight, IndentTop - currentHeight);
            RenderingContext ctx = new RenderingContext();
            ctx.pagetop = IndentTop;
            ctx.oldHeight = currentHeight;
            ctx.cellGraphics = new PdfContentByte(writer);
            ctx.rowspanMap = new Hashtable();
            ctx.table = table;

            // initialisation of parameters
            PdfCell cell;

            // drawing the table
            ArrayList headercells = table.HeaderCells;
            ArrayList cells = table.Cells;
            ArrayList rows = ExtractRows(cells, ctx);
            bool isContinue = false;
            while (cells.Count != 0) {
                // initialisation of some extra parameters;
                ctx.lostTableBottom = 0;

                // loop over the cells
                bool cellsShown = false;

                // draw the cells (line by line)
                ListIterator iterator = new ListIterator(rows);

                bool atLeastOneFits = false;
                while (iterator.HasNext()) {
                    ArrayList row = (ArrayList) iterator.Next();
                    AnalyzeRow(rows, ctx);
                    RenderCells(ctx, row, table.HasToFitPageCells() & atLeastOneFits);

                    if (!MayBeRemoved(row)) {
                        break;
                    }

                    ConsumeRowspan(row, ctx);
                    iterator.Remove();
                    atLeastOneFits = true;
                }

            //          compose cells array list for subsequent code
                cells.Clear();
                Hashtable opt = new Hashtable();
                foreach (ArrayList row in rows) {
                    foreach (PdfCell cellp in row) {
                        if (!opt.ContainsKey(cellp)) {
                            cells.Add(cellp);
                            opt[cellp] = null;
                        }
                    }
                }
                // we paint the graphics of the table after looping through all the cells
                Rectangle tablerec = new Rectangle(table);
                tablerec.Border = table.Border;
                tablerec.BorderWidth = table.BorderWidth;
                tablerec.BorderColor = table.BorderColor;
                tablerec.BackgroundColor = table.BackgroundColor;
                PdfContentByte under = writer.DirectContentUnder;
                under.Rectangle(tablerec.GetRectangle(Top, IndentBottom));
                under.Add(ctx.cellGraphics);
                // bugfix by Gerald Fehringer: now again add the border for the table
                // since it might have been covered by cell backgrounds
                tablerec.BackgroundColor = null;
                tablerec = tablerec.GetRectangle(Top, IndentBottom);
                tablerec.Border = table.Border;
                under.Rectangle(tablerec);
                // end bugfix
                ctx.cellGraphics = new PdfContentByte(null);
                // if the table continues on the next page
                if (rows.Count != 0) {
                    isContinue = true;
                    graphics.SetLineWidth(table.BorderWidth);
                    if (cellsShown && (table.Border & Rectangle.BOTTOM_BORDER) == Rectangle.BOTTOM_BORDER) {
                        // Draw the bottom line

                        // the color is set to the color of the element
                        Color tColor = table.BorderColor;
                        if (tColor != null) {
                            graphics.SetColorStroke(tColor);
                        }
                        graphics.MoveTo(table.Left, Math.Max(table.Bottom, IndentBottom));
                        graphics.LineTo(table.Right, Math.Max(table.Bottom, IndentBottom));
                        graphics.Stroke();
                        if (tColor != null) {
                            graphics.ResetRGBColorStroke();
                        }
                    }

//.........这里部分代码省略.........
开发者ID:bmictech,项目名称:iTextSharp,代码行数:101,代码来源:PdfDocument.cs


注:本文中的iTextSharp.text.Rectangle.GetRectangle方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。