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


C# pdf.PdfLine类代码示例

本文整理汇总了C#中iTextSharp.text.pdf.PdfLine的典型用法代码示例。如果您正苦于以下问题:C# PdfLine类的具体用法?C# PdfLine怎么用?C# PdfLine使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


PdfLine类属于iTextSharp.text.pdf命名空间,在下文中一共展示了PdfLine类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: CarriageReturn

 /**
 * If the current line is not empty or null, it is added to the arraylist
 * of lines and a new empty line is added.
 * @throws DocumentException on error
 */
 
 protected internal void CarriageReturn() {
     // the arraylist with lines may not be null
     if (lines == null) {
         lines = new ArrayList();
     }
     // If the current line is not null
     if (line != null) {
         // we check if the end of the page is reached (bugfix by Francois Gravel)
         if (currentHeight + line.Height + leading < IndentTop - IndentBottom) {
             // if so nonempty lines are added and the heigt is augmented
             if (line.Size > 0) {
                 currentHeight += line.Height;
                 lines.Add(line);
                 pageEmpty = false;
             }
         }
         // if the end of the line is reached, we start a new page
         else {
             NewPage();
         }
     }
     if (imageEnd > -1 && currentHeight > imageEnd) {
         imageEnd = -1;
         indentation.imageIndentRight = 0;
         indentation.imageIndentLeft = 0;
     }
     // a new current line is constructed
     line = new PdfLine(IndentLeft, IndentRight, alignment, leading);
 }
开发者ID:pusp,项目名称:o2platform,代码行数:35,代码来源:PdfDocument.cs

示例2: FlushLines

        /**
        * Writes all the lines to the text-object.
        *
        * @return the displacement that was caused
        * @throws DocumentException on error
        */
        protected internal float FlushLines() {
            // checks if the ArrayList with the lines is not null
            if (lines == null) {
                return 0;
            }
            // checks if a new Line has to be made.
            if (line != null && line.Size > 0) {
                lines.Add(line);
                line = new PdfLine(IndentLeft, IndentRight, alignment, leading);
            }
            
            // checks if the ArrayList with the lines is empty
            if (lines.Count == 0) {
                return 0;
            }
            
            // initialisation of some parameters
            Object[] currentValues = new Object[2];
            PdfFont currentFont = null;
            float displacement = 0;

            currentValues[1] = (float)0;
            // looping over all the lines
            foreach (PdfLine l in lines) {
                
                // this is a line in the loop
                
                float moveTextX = l.IndentLeft - IndentLeft + indentation.indentLeft + indentation.listIndentLeft + indentation.sectionIndentLeft;
                text.MoveText(moveTextX, -l.Height);
                // is the line preceeded by a symbol?
                if (l.ListSymbol != null) {
                    ColumnText.ShowTextAligned(graphics, Element.ALIGN_LEFT, new Phrase(l.ListSymbol), text.XTLM - l.ListIndent, text.YTLM, 0);
                }
                
                currentValues[0] = currentFont;
                
                WriteLineToContent(l, text, graphics, currentValues, writer.SpaceCharRatio);
                
                currentFont = (PdfFont)currentValues[0];
                
                displacement += l.Height;
                text.MoveText(-moveTextX, 0);
            }
            lines = new ArrayList();
            return displacement;
        }
开发者ID:pusp,项目名称:o2platform,代码行数:52,代码来源:PdfDocument.cs

示例3: FlushLines

        /**
        * Writes all the lines to the text-object.
        *
        * @return the displacement that was caused
        * @throws DocumentException on error
        */
        private float FlushLines()
        {
            // checks if the ArrayList with the lines is not null
            if (lines == null) {
                return 0;
            }
            bool newline=false;
            // checks if a new Line has to be made.
            if (line != null && line.Size > 0) {
                lines.Add(line);
                line = new PdfLine(IndentLeft, IndentRight, alignment, leading);
                newline=true;
            }

            // checks if the ArrayList with the lines is empty
            if (lines.Count == 0) {
                return 0;
            }

            // initialisation of some parameters
            Object[] currentValues = new Object[2];
            PdfFont currentFont = null;
            float displacement = 0;

            currentValues[1] = (float)0;
            // looping over all the lines
            foreach (PdfLine l in lines) {

                // this is a line in the loop

                if (isNewpage && newline) { // fix [email protected]
                    newline=false;
                    text.MoveText(l.IndentLeft - IndentLeft + listIndentLeft + paraIndent,-l.Height);
                }
                else {
                    text.MoveText(l.IndentLeft - IndentLeft + listIndentLeft, -l.Height);
                }

                // is the line preceeded by a symbol?
                if (l.ListSymbol != null) {
                    ColumnText.ShowTextAligned(graphics, Element.ALIGN_LEFT, new Phrase(l.ListSymbol), text.XTLM - l.ListIndent, text.YTLM, 0);
                }

                currentValues[0] = currentFont;

                WriteLineToContent(l, text, graphics, currentValues, writer.SpaceCharRatio);

                currentFont = (PdfFont)currentValues[0];

                displacement += l.Height;
                if (IndentLeft - listIndentLeft != l.IndentLeft) {
                    text.MoveText(IndentLeft - l.IndentLeft - listIndentLeft, 0);
                }

            }
            lines = new ArrayList();
            return displacement;
        }
开发者ID:hjgode,项目名称:iTextSharpCF,代码行数:64,代码来源:PdfDocument.cs

示例4: WriteLine

        internal void WriteLine(PdfLine line, PdfContentByte text, PdfContentByte graphics)
        {
            PdfFont currentFont = null;
            foreach(PdfChunk chunk in line) {
                if (chunk.Font.CompareTo(currentFont) != 0) {
                    currentFont = chunk.Font;
                    text.SetFontAndSize(currentFont.Font, currentFont.Size);
                }
                Object[] textRender = (Object[])chunk.GetAttribute(Chunk.TEXTRENDERMODE);
                int tr = 0;
                float strokeWidth = 1;
                BaseColor color = chunk.Color;
                BaseColor strokeColor = null;
                if (textRender != null) {
                    tr = (int)textRender[0] & 3;
                    if (tr != PdfContentByte.TEXT_RENDER_MODE_FILL)
                        text.SetTextRenderingMode(tr);
                    if (tr == PdfContentByte.TEXT_RENDER_MODE_STROKE || tr == PdfContentByte.TEXT_RENDER_MODE_FILL_STROKE) {
                        strokeWidth = (float)textRender[1];
                        if (strokeWidth != 1)
                            text.SetLineWidth(strokeWidth);
                        strokeColor = (BaseColor)textRender[2];
                        if (strokeColor == null)
                            strokeColor = color;
                        if (strokeColor != null)
                            text.SetColorStroke(strokeColor);
                    }
                }

                object charSpace = chunk.GetAttribute(Chunk.CHAR_SPACING);
                // no char space setting means "leave it as is".
                if (charSpace != null && !curCharSpace.Equals(charSpace)) {
                    curCharSpace = (float)charSpace;
                    text.SetCharacterSpacing(curCharSpace);
                }
                if (color != null)
                    text.SetColorFill(color);
                text.ShowText(chunk.ToString());
                if (color != null)
                    text.ResetRGBColorFill();
                if (tr != PdfContentByte.TEXT_RENDER_MODE_FILL)
                    text.SetTextRenderingMode(PdfContentByte.TEXT_RENDER_MODE_FILL);
                if (strokeColor != null)
                    text.ResetRGBColorStroke();
                if (strokeWidth != 1)
                    text.SetLineWidth(1);
            }
        }
开发者ID:mapo80,项目名称:iTextSharp-Monotouch,代码行数:48,代码来源:VerticalText.cs

示例5: AddLine

 // methods
 private void AddLine(PdfLine line)
 {
     lines.Add(line);
     contentHeight += line.Height;
     lastLine = line;
     this.line = null;
 }
开发者ID:hjgode,项目名称:iTextSharpCF,代码行数:8,代码来源:PdfCell.cs

示例6: FlushLines

        /**
        * Writes all the lines to the text-object.
        *
        * @return the displacement that was caused
        * @throws DocumentException on error
        */
        protected internal float FlushLines() {
            // checks if the ArrayList with the lines is not null
            if (lines == null) {
                return 0;
            }
            // checks if a new Line has to be made.
            if (line != null && line.Size > 0) {
                lines.Add(line);
                line = new PdfLine(IndentLeft, IndentRight, alignment, leading);
            }
            
            // checks if the ArrayList with the lines is empty
            if (lines.Count == 0) {
                return 0;
            }
            
            // initialisation of some parameters
            Object[] currentValues = new Object[2];
            PdfFont currentFont = null;
            float displacement = 0;

            currentValues[1] = (float)0;
            // looping over all the lines
            foreach (PdfLine l in lines) {
                
                // this is a line in the loop
                
                float moveTextX = l.IndentLeft - IndentLeft + indentation.indentLeft + indentation.listIndentLeft + indentation.sectionIndentLeft;
                text.MoveText(moveTextX, -l.Height);
                // is the line preceeded by a symbol?
                l.Flush();

                if (l.ListSymbol != null) {
                    ListLabel lbl = null;
                    Chunk symbol = l.ListSymbol;
                    if (IsTagged(writer))
                    {
                        lbl = l.listItem.ListLabel;
                        graphics.OpenMCBlock(lbl);
                        symbol = new Chunk(symbol);
                        if (!lbl.TagLabelContent)
                            symbol.Role = null;
                    }
                    ColumnText.ShowTextAligned(graphics, Element.ALIGN_LEFT, new Phrase(symbol), text.XTLM - l.ListIndent, text.YTLM, 0);
                    if (lbl != null)
                    {
                        graphics.CloseMCBlock(lbl);
                    }
                }
                
                currentValues[0] = currentFont;

                if (IsTagged(writer) && l.ListItem != null)
                    text.OpenMCBlock(l.listItem.ListBody);

                WriteLineToContent(l, text, graphics, currentValues, writer.SpaceCharRatio);
                
                currentFont = (PdfFont)currentValues[0];
                
                displacement += l.Height;
                text.MoveText(-moveTextX, 0);
            }
            lines = new List<PdfLine>();
            return displacement;
        }
开发者ID:NelsonSantos,项目名称:fyiReporting-Android,代码行数:71,代码来源:PdfDocument.cs

示例7: GetLines

        /**
         * Gets the lines of a cell that can be drawn between certain limits.
         * <P>
         * Remark: all the lines that can be drawn are removed from the object!
         *
         * @param   top     the top of the part of the table that can be drawn
         * @param   bottom  the bottom of the part of the table that can be drawn
         * @return  an <CODE>ArrayList</CODE> of <CODE>PdfLine</CODE>s
         */
        public ArrayList GetLines(float top, float bottom)
        {
            float lineHeight;
            float currentPosition = Math.Min(this.Top, top);
            this.Top = currentPosition + cellspacing;
            ArrayList result = new ArrayList();

            // if the bottom of the page is higher than the top of the cell: do nothing
            if (Top < bottom) {
                return result;
            }

            // we loop over the lines
            int size = lines.Count;
            bool aboveBottom = true;
            for (int i = 0; i < size && aboveBottom; i++) {
                line = (PdfLine) lines[i];
                lineHeight = line.Height;
                currentPosition -= lineHeight;
                // if the currentPosition is higher than the bottom, we add the line to the result
                if (currentPosition > (bottom + cellpadding + GetBorderWidthInside(BOTTOM_BORDER))) { // bugfix by Tom Ring and Veerendra Namineni
                    result.Add(line);
                }
                else {
                    aboveBottom = false;
                }
            }
            // if the bottom of the cell is higher than the bottom of the page, the cell is written, so we can remove all lines
            float difference = 0f;
            if (!header) {
                if (aboveBottom) {
                    lines = new ArrayList();
                    contentHeight = 0f;
                }
                else {
                    size = result.Count;
                    for (int i = 0; i < size; i++) {
                        line = RemoveLine(0);
                        difference += line.Height;
                    }
                }
            }
            if (difference > 0) {
                foreach (Image image in images) {
                    image.SetAbsolutePosition(image.AbsoluteX, image.AbsoluteY - difference - leading);
                }
            }
            return result;
        }
开发者ID:hjgode,项目名称:iTextSharpCF,代码行数:58,代码来源:PdfCell.cs

示例8: AddImage

        /**
        * Adds an image to this Cell.
        *
        * @param i           the image to add
        * @param left        the left border
        * @param right       the right border
        * @param extraHeight extra height to add above image
        * @param alignment   horizontal alignment (constant from Element class)
        * @return the height of the image
        */
        private float AddImage(Image i, float left, float right, float extraHeight, int alignment)
        {
            Image image = Image.GetInstance(i);
            if (image.ScaledWidth > right - left) {
                image.ScaleToFit(right - left, float.MaxValue);
            }
            FlushCurrentLine();
            if (line == null) {
                line = new PdfLine(left, right, alignment, leading);
            }
            PdfLine imageLine = line;

            // left and right in chunk is relative to the start of the line
            right = right - left;
            left = 0f;

            if ((image.Alignment & Image.RIGHT_ALIGN) == Image.RIGHT_ALIGN) { // fix Uwe Zimmerman
                left = right - image.ScaledWidth;
            } else if ((image.Alignment & Image.MIDDLE_ALIGN) == Image.MIDDLE_ALIGN) {
                left = left + ((right - left - image.ScaledWidth) / 2f);
            }
            Chunk imageChunk = new Chunk(image, left, 0);
            imageLine.Add(new PdfChunk(imageChunk, null));
            AddLine(imageLine);
            return imageLine.Height;
        }
开发者ID:hjgode,项目名称:iTextSharpCF,代码行数:36,代码来源:PdfCell.cs

示例9: PdfCell

        // constructors
        /**
         * Constructs a <CODE>PdfCell</CODE>-object.
         *
         * @param   cell        the original <CODE>Cell</CODE>
         * @param   rownumber   the number of the <CODE>Row</CODE> the <CODE>Cell</CODE> was in.
         * @param   left        the left border of the <CODE>PdfCell</CODE>
         * @param   right       the right border of the <CODE>PdfCell</CODE>
         * @param   top         the top border of the <CODE>PdfCell</CODE>
         * @param   cellspacing the cellspacing of the <CODE>Table</CODE>
         * @param   cellpadding the cellpadding of the <CODE>Table</CODE>
         */
        public PdfCell(Cell cell, int rownumber, float left, float right, float top, float cellspacing, float cellpadding)
            : base(left, top, right, top)
        {
            // copying the other Rectangle attributes from class Cell
            CloneNonPositionParameters(cell);
            this.cellpadding = cellpadding;
            this.cellspacing = cellspacing;
            this.verticalAlignment = cell.VerticalAlignment;
            this.useAscender = cell.UseAscender;
            this.useDescender = cell.UseDescender;
            this.useBorderPadding = cell.UseBorderPadding;

            // initialisation of some parameters
            PdfChunk chunk;
            PdfChunk overflow;
            lines = new ArrayList();
            images = new ArrayList();
            leading = cell.Leading;
            int alignment = cell.HorizontalAlignment;
            left += cellspacing + cellpadding;
            right -= cellspacing + cellpadding;

            left += GetBorderWidthInside(LEFT_BORDER);
            right -= GetBorderWidthInside(RIGHT_BORDER);
            contentHeight = 0;
            rowspan = cell.Rowspan;

            ArrayList allActions;
            int aCounter;
            // we loop over all the elements of the cell
            foreach (IElement ele in cell.Elements) {
                switch (ele.Type) {
                    case Element.JPEG:
                    case Element.IMGRAW:
                    case Element.IMGTEMPLATE:
                        AddImage((Image)ele, left, right, 0.4f * leading, alignment);
                        break;
                        // if the element is a list
                    case Element.LIST:
                        if (line != null && line.Size > 0) {
                            line.ResetAlignment();
                            AddLine(line);
                        }
                        allActions = new ArrayList();
                        ProcessActions(ele, null, allActions);
                        aCounter = 0;
                        // we loop over all the listitems
                        foreach (ListItem item in ((List)ele).Items) {
                            line = new PdfLine(left + item.IndentationLeft, right, alignment, item.Leading);
                            line.ListItem = item;
                            foreach (Chunk c in item.Chunks) {
                                chunk = new PdfChunk(c, (PdfAction)(allActions[aCounter++]));
                                while ((overflow = line.Add(chunk)) != null) {
                                    AddLine(line);
                                    line = new PdfLine(left + item.IndentationLeft, right, alignment, item.Leading);
                                    chunk = overflow;
                                }
                                line.ResetAlignment();
                                AddLine(line);
                                line = new PdfLine(left + item.IndentationLeft, right, alignment, leading);
                            }
                        }
                        line = new PdfLine(left, right, alignment, leading);
                        break;
                        // if the element is something else
                    default:
                        allActions = new ArrayList();
                        ProcessActions(ele, null, allActions);
                        aCounter = 0;

                        float currentLineLeading = leading;
                        float currentLeft = left;
                        float currentRight = right;
                        if (ele is Phrase) {
                            currentLineLeading = ((Phrase) ele).Leading;
                        }
                        if (ele is Paragraph) {
                            Paragraph p = (Paragraph) ele;
                            currentLeft += p.IndentationLeft;
                            currentRight -= p.IndentationRight;
                        }
                        if (line == null) {
                            line = new PdfLine(currentLeft, currentRight, alignment, currentLineLeading);
                        }
                        // we loop over the chunks
                        ArrayList chunks = ele.Chunks;
                        if (chunks.Count == 0) {
                            AddLine(line); // add empty line - all cells need some lines even if they are empty
//.........这里部分代码省略.........
开发者ID:hjgode,项目名称:iTextSharpCF,代码行数:101,代码来源:PdfCell.cs

示例10: RemainingLinesHeight

     /**
      * Returns the total height of all the lines in the cell.
      *
      * @return  a value
      */
 
     private float RemainingLinesHeight() {
         if (lines.Count == 0) return 0;
         float result = 0;
         int size = lines.Count;
         PdfLine line;
         for (int i = 0; i < size; i++) {
             line = (PdfLine) lines[i];
             result += line.Height;
         }
         return result;
     }
开发者ID:nicecai,项目名称:iTextSharp-4.1.6,代码行数:17,代码来源:PdfCell.cs

示例11: AddList

 private void AddList(List list, float left, float right, int alignment) {
     PdfChunk chunk;
     PdfChunk overflow;
     ArrayList allActions = new ArrayList();
     ProcessActions(list, null, allActions);
     int aCounter = 0;
     foreach (IElement ele in list.Items) {
         switch (ele.Type) {
             case Element.LISTITEM:
                 ListItem item = (ListItem)ele;
                 line = new PdfLine(left + item.IndentationLeft, right, alignment, item.Leading);
                 line.ListItem = item;
                 foreach (Chunk c in item.Chunks) {
                     chunk = new PdfChunk(c, (PdfAction)(allActions[aCounter++]));
                     while ((overflow = line.Add(chunk)) != null) { 
                         AddLine(line);
                         line = new PdfLine(left + item.IndentationLeft, right, alignment, item.Leading);
                         chunk = overflow;
                     }
                     line.ResetAlignment();
                     AddLine(line);
                     line = new PdfLine(left + item.IndentationLeft, right, alignment, leading);
                 }
                 break;
             case Element.LIST:
                 List sublist = (List)ele;
                 AddList(sublist, left + sublist.IndentationLeft, right, alignment);
                 break;
         }
     }
 }
开发者ID:nicecai,项目名称:iTextSharp-4.1.6,代码行数:31,代码来源:PdfCell.cs

示例12: NewLine

 /**
 * Adds the current line to the list of lines and also adds an empty line.
 * @throws DocumentException on error
 */
 
 protected internal void NewLine() {
     lastElementType = -1;
     CarriageReturn();
     if (lines != null && lines.Count > 0) {
         lines.Add(line);
         currentHeight += line.Height;
     }
     line = new PdfLine(IndentLeft, IndentRight, alignment, leading);
 }
开发者ID:NelsonSantos,项目名称:fyiReporting-Android,代码行数:14,代码来源:PdfDocument.cs

示例13: RemoveLine

 private PdfLine RemoveLine(int index)
 {
     PdfLine oldLine = (PdfLine)lines[index];
     lines.RemoveAt(index);
     contentHeight -= oldLine.Height;
     if (index == 0) {
         if (lines.Count > 0) {
             firstLine = (PdfLine) lines[0];
             float firstLineRealHeight = FirstLineRealHeight;
             contentHeight -= firstLine.Height;
             firstLine.height = firstLineRealHeight;
             contentHeight += firstLineRealHeight;
         }
     }
     return oldLine;
 }
开发者ID:hjgode,项目名称:iTextSharpCF,代码行数:16,代码来源:PdfCell.cs

示例14: CarriageReturn

 /**
 * If the current line is not empty or null, it is added to the arraylist
 * of lines and a new empty line is added.
 * @throws DocumentException on error
 */
 
 protected internal void CarriageReturn() {
     // the arraylist with lines may not be null
     if (lines == null) {
         lines = new List<PdfLine>();
     }
     // If the current line is not null or empty
     if (line != null && line.Size > 0) {
         // we check if the end of the page is reached (bugfix by Francois Gravel)
         if (currentHeight + line.Height + leading > IndentTop - IndentBottom) {
             // if the end of the line is reached, we start a newPage which will flush existing lines
             // then move to next page but before then we need to exclude the current one that does not fit
             // After the new page we add the current line back in
             PdfLine overflowLine = line;
             line = null;
             NewPage();
             line = overflowLine;
             //update left indent because of mirror margins.
             overflowLine.left = IndentLeft;
         }
         currentHeight += line.Height;
         lines.Add(line);
         pageEmpty = false;
     }
     if (imageEnd > -1 && currentHeight > imageEnd) {
         imageEnd = -1;
         indentation.imageIndentRight = 0;
         indentation.imageIndentLeft = 0;
     }
     // a new current line is constructed
     line = new PdfLine(IndentLeft, IndentRight, alignment, leading);
 }
开发者ID:NelsonSantos,项目名称:fyiReporting-Android,代码行数:37,代码来源:PdfDocument.cs

示例15: WriteLine

 internal void WriteLine(PdfLine line, PdfContentByte text, PdfContentByte graphics)
 {
     PdfFont currentFont = null;
     foreach(PdfChunk chunk in line) {
         if (chunk.Font.CompareTo(currentFont) != 0) {
             currentFont = chunk.Font;
             text.SetFontAndSize(currentFont.Font, currentFont.Size);
         }
         BaseColor color = chunk.Color;
         object charSpace = chunk.GetAttribute(Chunk.CHAR_SPACING);
         // no char space setting means "leave it as is".
         if (charSpace != null && !curCharSpace.Equals(charSpace)) {
             curCharSpace = (float)charSpace;
             text.SetCharacterSpacing(curCharSpace);
         }
         if (color != null)
             text.SetColorFill(color);
         text.ShowText(chunk.ToString());
         if (color != null)
             text.ResetRGBColorFill();
     }
 }
开发者ID:jomamorales,项目名称:createPDF,代码行数:22,代码来源:VerticalText.cs


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