• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# pdf.PdfLine类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: WriteLineToContent

        /**
        * Writes a text line to the document. It takes care of all the attributes.
        * <P>
        * Before entering the line position must have been established and the
        * <CODE>text</CODE> argument must be in text object scope (<CODE>beginText()</CODE>).
        * @param line the line to be written
        * @param text the <CODE>PdfContentByte</CODE> where the text will be written to
        * @param graphics the <CODE>PdfContentByte</CODE> where the graphics will be written to
        * @param currentValues the current font and extra spacing values
        * @param ratio
        * @throws DocumentException on error
        */
        internal float WriteLineToContent(PdfLine line, PdfContentByte text, PdfContentByte graphics, Object[] currentValues, float ratio)  {
            PdfFont currentFont = (PdfFont)(currentValues[0]);
            float lastBaseFactor = (float)currentValues[1];
            //PdfChunk chunkz;
            int numberOfSpaces;
            int lineLen;
            bool isJustified;
            float hangingCorrection = 0;
            float hScale = 1;
            float lastHScale = float.NaN;
            float baseWordSpacing = 0;
            float baseCharacterSpacing = 0;
            float glueWidth = 0;
            float lastX = text.XTLM + line.OriginalWidth;
            
            numberOfSpaces = line.NumberOfSpaces;
            lineLen = line.GetLineLengthUtf32();
            // does the line need to be justified?
            isJustified = line.HasToBeJustified() && (numberOfSpaces != 0 || lineLen > 1);
            int separatorCount = line.GetSeparatorCount();
            if (separatorCount > 0) {
                glueWidth = line.WidthLeft / separatorCount;
            }
            else if (isJustified && separatorCount == 0) {
                if (line.NewlineSplit && line.WidthLeft >= (lastBaseFactor * (ratio * numberOfSpaces + lineLen - 1))) {
                    if (line.RTL) {
                        text.MoveText(line.WidthLeft - lastBaseFactor * (ratio * numberOfSpaces + lineLen - 1), 0);
                    }
                    baseWordSpacing = ratio * lastBaseFactor;
                    baseCharacterSpacing = lastBaseFactor;
                }
                else {
                    float width = line.WidthLeft;
                    PdfChunk last = line.GetChunk(line.Size - 1);
                    if (last != null) {
                        String s = last.ToString();
                        char c;
                        if (s.Length > 0 && hangingPunctuation.IndexOf((c = s[s.Length - 1])) >= 0) {
                            float oldWidth = width;
                            width += last.Font.Width(c) * 0.4f;
                            hangingCorrection = width - oldWidth;
                        }
                    }
                    float baseFactor = width / (ratio * numberOfSpaces + lineLen - 1);
                    baseWordSpacing = ratio * baseFactor;
                    baseCharacterSpacing = baseFactor;
                    lastBaseFactor = baseFactor;
                }
            }
            else if (line.alignment == Element.ALIGN_LEFT || line.alignment == Element.ALIGN_UNDEFINED) {
                lastX -= line.WidthLeft;
            }
            
            int lastChunkStroke = line.LastStrokeChunk;
            int chunkStrokeIdx = 0;
            float xMarker = text.XTLM;
            float baseXMarker = xMarker;
            float yMarker = text.YTLM;
            bool adjustMatrix = false;
            float tabPosition = 0;
            
            // looping over all the chunks in 1 line
            foreach (PdfChunk chunk in line) {
                if (IsTagged(writer) && chunk.accessibleElement != null) {
                    text.OpenMCBlock(chunk.accessibleElement);
                }
                BaseColor color = chunk.Color;
                float fontSize = chunk.Font.Size;
                float ascender;
                float descender;
                if (chunk.IsImage())
                {
                    ascender = chunk.Height();
                    descender = 0;
                }
                else
                {
                    ascender = chunk.Font.Font.GetFontDescriptor(BaseFont.ASCENT, fontSize);
                    descender = chunk.Font.Font.GetFontDescriptor(BaseFont.DESCENT, fontSize);
                }
                hScale = 1;
                
                if (chunkStrokeIdx <= lastChunkStroke) {
                    float width;
                    if (isJustified) {
                        width = chunk.GetWidthCorrected(baseCharacterSpacing, baseWordSpacing);
                    }
                    else {
//.........这里部分代码省略.........
开发者ID:NelsonSantos,项目名称:fyiReporting-Android,代码行数:101,代码来源:PdfDocument.cs


示例17: WriteLineToContent

        /**
        * Writes a text line to the document. It takes care of all the attributes.
        * <P>
        * Before entering the line position must have been established and the
        * <CODE>text</CODE> argument must be in text object scope (<CODE>beginText()</CODE>).
        * @param line the line to be written
        * @param text the <CODE>PdfContentByte</CODE> where the text will be written to
        * @param graphics the <CODE>PdfContentByte</CODE> where the graphics will be written to
        * @param currentValues the current font and extra spacing values
        * @param ratio
        * @throws DocumentException on error
        */
        internal void WriteLineToContent(PdfLine line, PdfContentByte text, PdfContentByte graphics, Object[] currentValues, float ratio)
        {
            PdfFont currentFont = (PdfFont)(currentValues[0]);
            float lastBaseFactor = (float)currentValues[1];
            //PdfChunk chunkz;
            int numberOfSpaces;
            int lineLen;
            bool isJustified;
            float hangingCorrection = 0;
            float hScale = 1;
            float lastHScale = float.NaN;
            float baseWordSpacing = 0;
            float baseCharacterSpacing = 0;

            numberOfSpaces = line.NumberOfSpaces;
            lineLen = line.ToString().Length;
            // does the line need to be justified?
            isJustified = line.HasToBeJustified() && (numberOfSpaces != 0 || lineLen > 1);
            if (isJustified) {
                if (line.NewlineSplit && line.WidthLeft >= (lastBaseFactor * (ratio * numberOfSpaces + lineLen - 1))) {
                    if (line.RTL) {
                        text.MoveText(line.WidthLeft - lastBaseFactor * (ratio * numberOfSpaces + lineLen - 1), 0);
                    }
                    baseWordSpacing = ratio * lastBaseFactor;
                    baseCharacterSpacing = lastBaseFactor;
                }
                else {
                    float width = line.WidthLeft;
                    PdfChunk last = line.GetChunk(line.Size - 1);
                    if (last != null) {
                        String s = last.ToString();
                        char c;
                        if (s.Length > 0 && hangingPunctuation.IndexOf((c = s[s.Length - 1])) >= 0) {
                            float oldWidth = width;
                            width += last.Font.Width(c) * 0.4f;
                            hangingCorrection = width - oldWidth;
                        }
                    }
                    float baseFactor = width / (ratio * numberOfSpaces + lineLen - 1);
                    baseWordSpacing = ratio * baseFactor;
                    baseCharacterSpacing = baseFactor;
                    lastBaseFactor = baseFactor;
                }
            }

            int lastChunkStroke = line.LastStrokeChunk;
            int chunkStrokeIdx = 0;
            float xMarker = text.XTLM;
            float baseXMarker = xMarker;
            float yMarker = text.YTLM;
            bool adjustMatrix = false;

            // looping over all the chunks in 1 line
            foreach (PdfChunk chunk in line) {
                Color color = chunk.Color;
                hScale = 1;

                if (chunkStrokeIdx <= lastChunkStroke) {
                    float width;
                    if (isJustified) {
                        width = chunk.GetWidthCorrected(baseCharacterSpacing, baseWordSpacing);
                    }
                    else
                        width = chunk.Width;
                    if (chunk.IsStroked()) {
                        PdfChunk nextChunk = line.GetChunk(chunkStrokeIdx + 1);
                        if (chunk.IsAttribute(Chunk.BACKGROUND)) {
                            float subtract = lastBaseFactor;
                            if (nextChunk != null && nextChunk.IsAttribute(Chunk.BACKGROUND))
                                subtract = 0;
                            if (nextChunk == null)
                                subtract += hangingCorrection;
                            float fontSize = chunk.Font.Size;
                            float ascender = chunk.Font.Font.GetFontDescriptor(BaseFont.ASCENT, fontSize);
                            float descender = chunk.Font.Font.GetFontDescriptor(BaseFont.DESCENT, fontSize);
                            Object[] bgr = (Object[])chunk.GetAttribute(Chunk.BACKGROUND);
                            graphics.SetColorFill((Color)bgr[0]);
                            float[] extra = (float[])bgr[1];
                            graphics.Rectangle(xMarker - extra[0],
                                yMarker + descender - extra[1] + chunk.TextRise,
                                width - subtract + extra[0] + extra[2],
                                ascender - descender + extra[1] + extra[3]);
                            graphics.Fill();
                            graphics.SetGrayFill(0);
                        }
                        if (chunk.IsAttribute(Chunk.UNDERLINE)) {
                            float subtract = lastBaseFactor;
                            if (nextChunk != null && nextChunk.IsAttribute(Chunk.UNDERLINE))
//.........这里部分代码省略.........
开发者ID:hjgode,项目名称:iTextSharpCF,代码行数:101,代码来源:PdfDocument.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# pdf.PdfLiteral类代码示例发布时间:2022-05-26
下一篇:
C# pdf.PdfLayer类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap