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

C# pdf.PdfChunk类代码示例

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

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



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

示例1: GetCurrentCharacter

 /**
  * Returns the current character
  * @param current current position in the array
  * @param	cc		the character array that has to be checked
  * @param ck chunk array
  * @return	the current character
  */
 protected char GetCurrentCharacter(int current, char[] cc, PdfChunk[] ck)
 {
     if (ck == null)
     {
         return (char)cc[current];
     }
     return (char)ck[Math.Min(current, ck.Length - 1)].GetUnicodeEquivalent(cc[current]);
 }
开发者ID:Bloodrider,项目名称:wsFacturizate,代码行数:15,代码来源:PFI730206632.cs


示例2: IsSplitCharacter

// ===========================================================================
    /**
     * @see com.itextpdf.text.SplitCharacter#isSplitCharacter(int, int, int, char[],
     *      com.itextpdf.text.pdf.PdfChunk[])
     */
    public bool IsSplitCharacter(
      int start, int current, int end, char[] cc, PdfChunk[] ck) 
    {
      char c = ck == null
        ? cc[current]
        : (char) ck[Math.Min(current, ck.Length - 1)]
            .GetUnicodeEquivalent(cc[current])
      ;
      return (c == '|' || c <= ' ' || c == '-');
    }
开发者ID:,项目名称:,代码行数:15,代码来源:


示例3: IsSplitCharacter

 /**
  * Checks if a character can be used to split a <CODE>PdfString</CODE>.
  * <P>
  * for the moment every character less than or equal to SPACE, the character '-'
  * and some specific unicode ranges are 'splitCharacters'.
  * 
  * @param start start position in the array
  * @param current current position in the array
  * @param end end position in the array
  * @param	cc		the character array that has to be checked
  * @param ck chunk array
  * @return	<CODE>true</CODE> if the character can be used to split a string, <CODE>false</CODE> otherwise
  */
 public bool IsSplitCharacter(int start, int current, int end, char[] cc, PdfChunk[] ck) {
     char c = GetCurrentCharacter(current, cc, ck);
     if (c <= ' ' || c == '-' || c == '\u2010') {
         return true;
     }
     if (c < 0x2002)
         return false;
     return ((c >= 0x2002 && c <= 0x200b)
         || (c >= 0x2e80 && c < 0xd7a0)
         || (c >= 0xf900 && c < 0xfb00)
         || (c >= 0xfe30 && c < 0xfe50)
         || (c >= 0xff61 && c < 0xffa0));
 }
开发者ID:pusp,项目名称:o2platform,代码行数:26,代码来源:DefaultSplitCharacter.cs


示例4: Add

        /**
        * Signals that an <CODE>Element</CODE> was added to the <CODE>Document</CODE>.
        *
        * @param element the element to add
        * @return <CODE>true</CODE> if the element was added, <CODE>false</CODE> if not.
        * @throws DocumentException when a document isn't open yet, or has been closed
        */
        public override bool Add(IElement element)
        {
            if (writer != null && writer.IsPaused()) {
                return false;
            }
            switch (element.Type) {

                // Information (headers)
                case Element.HEADER:
                    info.Addkey(((Meta)element).Name, ((Meta)element).Content);
                    break;
                case Element.TITLE:
                    info.AddTitle(((Meta)element).Content);
                    break;
                case Element.SUBJECT:
                    info.AddSubject(((Meta)element).Content);
                    break;
                case Element.KEYWORDS:
                    info.AddKeywords(((Meta)element).Content);
                    break;
                case Element.AUTHOR:
                    info.AddAuthor(((Meta)element).Content);
                    break;
                case Element.CREATOR:
                    info.AddCreator(((Meta)element).Content);
                    break;
                case Element.PRODUCER:
                    // you can not change the name of the producer
                    info.AddProducer();
                    break;
                case Element.CREATIONDATE:
                    // you can not set the creation date, only reset it
                    info.AddCreationDate();
                    break;

                    // content (text)
                case Element.CHUNK: {
                    // if there isn't a current line available, we make one
                    if (line == null) {
                        CarriageReturn();
                    }

                    // we cast the element to a chunk
                    PdfChunk chunk = new PdfChunk((Chunk) element, anchorAction);
                    // we try to add the chunk to the line, until we succeed
                    {
                        PdfChunk overflow;
                        while ((overflow = line.Add(chunk)) != null) {
                            CarriageReturn();
                            chunk = overflow;
                            chunk.TrimFirstSpace();
                        }
                    }
                    pageEmpty = false;
                    if (chunk.IsAttribute(Chunk.NEWPAGE)) {
                        NewPage();
                    }
                    break;
                }
                case Element.ANCHOR: {
                    Anchor anchor = (Anchor) element;
                    String url = anchor.Reference;
                    leading = anchor.Leading;
                    if (url != null) {
                        anchorAction = new PdfAction(url);
                    }

                    // we process the element
                    element.Process(this);
                    anchorAction = null;
                    break;
                }
                case Element.ANNOTATION: {
                    if (line == null) {
                        CarriageReturn();
                    }
                    Annotation annot = (Annotation) element;
                    Rectangle rect = new Rectangle(0, 0);
                    if (line != null)
                        rect = new Rectangle(annot.GetLlx(IndentRight - line.WidthLeft), annot.GetLly(IndentTop - currentHeight), annot.GetUrx(IndentRight - line.WidthLeft + 20), annot.GetUry(IndentTop - currentHeight - 20));
                    PdfAnnotation an = PdfAnnotationsImp.ConvertAnnotation(writer, annot, rect);
                    annotationsImp.AddPlainAnnotation(an);
                    pageEmpty = false;
                    break;
                }
                case Element.PHRASE: {
                    // we cast the element to a phrase and set the leading of the document
                    leading = ((Phrase) element).Leading;
                    // we process the element
                    element.Process(this);
                    break;
                }
                case Element.PARAGRAPH: {
//.........这里部分代码省略.........
开发者ID:hjgode,项目名称:iTextSharpCF,代码行数:101,代码来源:PdfDocument.cs


示例5: Truncate

     /**
      * Truncates this <CODE>PdfChunk</CODE> if it's too long for the given width.
      * <P>
      * Returns <VAR>null</VAR> if the <CODE>PdfChunk</CODE> wasn't truncated.
      *
      * @param       width       a given width
      * @return      the <CODE>PdfChunk</CODE> that doesn't fit into the width.
      */
 
     internal PdfChunk Truncate(float width) {
         if (image != null) {
             if (image.ScaledWidth > width) {
                 PdfChunk pc = new PdfChunk("", this);
                 value = "";
                 attributes.Remove(Chunk.IMAGE);
                 image = null;
                 font = PdfFont.DefaultFont;
                 return pc;
             }
             else
                 return null;
         }
     
         int currentPosition = 0;
         float currentWidth = 0;
     
         // it's no use trying to split if there isn't even enough place for a space
         if (width < font.Width()) {
             string returnValue = value.Substring(1);
             value = value.Substring(0, 1);
             PdfChunk pc = new PdfChunk(returnValue, this);
             return pc;
         }
     
         // loop over all the characters of a string
         // or until the totalWidth is reached
         int length = value.Length;
         bool surrogate = false;
         while (currentPosition < length) {
             // the width of every character is added to the currentWidth
             surrogate = Utilities.IsSurrogatePair(value, currentPosition);
             if (surrogate)
                 currentWidth += GetCharWidth(Utilities.ConvertToUtf32(value, currentPosition));
             else
                 currentWidth += GetCharWidth(value[currentPosition]);
             if (currentWidth > width)
                 break;
             if (surrogate)
                 currentPosition++;
             currentPosition++;
         }
     
         // if all the characters fit in the total width, null is returned (there is no overflow)
         if (currentPosition == length) {
             return null;
         }
     
         // otherwise, the string has to be truncated
         //currentPosition -= 2;
         // we have to chop off minimum 1 character from the chunk
         if (currentPosition == 0) {
             currentPosition = 1;
             if (surrogate)
                 ++currentPosition;
         }
         string retVal = value.Substring(currentPosition);
         value = value.Substring(0, currentPosition);
         PdfChunk tmp = new PdfChunk(retVal, this);
         return tmp;
     }
开发者ID:,项目名称:,代码行数:70,代码来源:


示例6: PdfChunk

     // constructors
 
     /**
      * Constructs a <CODE>PdfChunk</CODE>-object.
      *
      * @param string the content of the <CODE>PdfChunk</CODE>-object
      * @param font the <CODE>PdfFont</CODE>
      * @param attributes the metrics attributes
      * @param noStroke the non metric attributes
      */
 
     internal PdfChunk(string str, PdfChunk other) {
         thisChunk[0] = this;
         value = str;
         this.font = other.font;
         this.attributes = other.attributes;
         this.noStroke = other.noStroke;
         this.baseFont = other.baseFont;
         Object[] obj = null;
         if (attributes.ContainsKey(Chunk.IMAGE))
             obj = (Object[])attributes[Chunk.IMAGE];
         if (obj == null)
             image = null;
         else {
             image = (Image)obj[0];
             offsetX = (float)obj[1];
             offsetY = (float)obj[2];
             changeLeading = (bool)obj[3];
         }
         encoding = font.Font.Encoding;
         if (noStroke.ContainsKey(Chunk.SPLITCHARACTER))
             splitCharacter = (ISplitCharacter)noStroke[Chunk.SPLITCHARACTER];
         else
             splitCharacter = DefaultSplitCharacter.DEFAULT;
     }
开发者ID:,项目名称:,代码行数:35,代码来源:


示例7: Add

        /**
        * Signals that an <CODE>Element</CODE> was added to the <CODE>Document</CODE>.
        *
        * @param element the element to add
        * @return <CODE>true</CODE> if the element was added, <CODE>false</CODE> if not.
        * @throws DocumentException when a document isn't open yet, or has been closed
        */
        public override bool Add(IElement element) {
            if (writer != null && writer.IsPaused()) {
                return false;
            }
            if (element.Type != Element.DIV) {
                FlushFloatingElements();
            }
            switch (element.Type) {
                
                // Information (headers)
                case Element.HEADER:
                    info.Addkey(((Meta)element).Name, ((Meta)element).Content);
                    break;
                case Element.TITLE:
                    info.AddTitle(((Meta)element).Content);
                    break;
                case Element.SUBJECT:
                    info.AddSubject(((Meta)element).Content);
                    break;
                case Element.KEYWORDS:
                    info.AddKeywords(((Meta)element).Content);
                    break;
                case Element.AUTHOR:
                    info.AddAuthor(((Meta)element).Content);
                    break;
                case Element.CREATOR:
                    info.AddCreator(((Meta)element).Content);
                    break;
                case Element.LANGUAGE:
                    SetLanguage(((Meta)element).Content);
                    break;
                case Element.PRODUCER:
                    // you can not change the name of the producer
                    info.AddProducer();
                    break;
                case Element.CREATIONDATE:
                    // you can not set the creation date, only reset it
                    info.AddCreationDate();
                    break;
                    
                    // content (text)
                case Element.CHUNK: {
                    // if there isn't a current line available, we make one
                    if (line == null) {
                        CarriageReturn();
                    }
                    
                    // we cast the element to a chunk
                    PdfChunk chunk = new PdfChunk((Chunk) element, anchorAction, tabSettings);
                    // we try to add the chunk to the line, until we succeed
                    {
                        PdfChunk overflow;
                        while ((overflow = line.Add(chunk)) != null) {
                            CarriageReturn();
                            bool newlineSplit = chunk.IsNewlineSplit();
                            chunk = overflow;
                            if (!newlineSplit)
                                chunk.TrimFirstSpace();
                        }
                    }
                    pageEmpty = false;
                    if (chunk.IsAttribute(Chunk.NEWPAGE)) {
                        NewPage();
                    }
                    break;
                }
                case Element.ANCHOR: {
                    Anchor anchor = (Anchor) element;
                    String url = anchor.Reference;
                    leading = anchor.Leading;
                    PushLeading();
                    if (url != null) {
                        anchorAction = new PdfAction(url);
                    }
                    
                    // we process the element
                    element.Process(this);
                    anchorAction = null;
                    PopLeading();
                    break;
                }
                case Element.ANNOTATION: {
                    if (line == null) {
                        CarriageReturn();
                    }
                    Annotation annot = (Annotation) element;
                    Rectangle rect = new Rectangle(0, 0);
                    if (line != null)
                        rect = new Rectangle(annot.GetLlx(IndentRight - line.WidthLeft), annot.GetUry(IndentTop - currentHeight - 20), annot.GetUrx(IndentRight - line.WidthLeft + 20), annot.GetLly(IndentTop - currentHeight));
                    PdfAnnotation an = PdfAnnotationsImp.ConvertAnnotation(writer, annot, rect);
                    annotationsImp.AddPlainAnnotation(an);
                    pageEmpty = false;
                    break;
//.........这里部分代码省略.........
开发者ID:NelsonSantos,项目名称:fyiReporting-Android,代码行数:101,代码来源:PdfDocument.cs


示例8: ProcessLine

 public PdfLine ProcessLine(float leftX, float width, int alignment, int runDirection, int arabicOptions)
 {
     this.arabicOptions = arabicOptions;
     Save();
     bool isRTL = (runDirection == PdfWriter.RUN_DIRECTION_RTL);
     if (currentChar >= totalTextLength) {
         bool hasText = GetParagraph(runDirection);
         if (!hasText)
             return null;
         if (totalTextLength == 0) {
             ArrayList ar = new ArrayList();
             PdfChunk ckx = new PdfChunk("", detailChunks[0]);
             ar.Add(ckx);
             return new PdfLine(0, 0, 0, alignment, true, ar, isRTL);
         }
     }
     float originalWidth = width;
     int lastSplit = -1;
     if (currentChar != 0)
         currentChar = TrimLeftEx(currentChar, totalTextLength - 1);
     int oldCurrentChar = currentChar;
     int uniC = 0;
     PdfChunk ck = null;
     float charWidth = 0;
     PdfChunk lastValidChunk = null;
     bool splitChar = false;
     bool surrogate = false;
     for (; currentChar < totalTextLength; ++currentChar) {
         ck = detailChunks[currentChar];
         surrogate = Utilities.IsSurrogatePair(text, currentChar);
         if (surrogate)
             uniC = ck.GetUnicodeEquivalent(Utilities.ConvertToUtf32(text, currentChar));
         else
             uniC = ck.GetUnicodeEquivalent(text[currentChar]);
         if (PdfChunk.NoPrint(uniC))
             continue;
         if (surrogate)
             charWidth = ck.GetCharWidth(uniC);
         else
             charWidth = ck.GetCharWidth(text[currentChar]);
         splitChar = ck.IsExtSplitCharacter(oldCurrentChar, currentChar, totalTextLength, text, detailChunks);
         if (splitChar && Char.IsWhiteSpace((char)uniC))
             lastSplit = currentChar;
         if (width - charWidth < 0)
             break;
         if (splitChar)
             lastSplit = currentChar;
         width -= charWidth;
         lastValidChunk = ck;
         if (surrogate)
             ++currentChar;
         if (ck.IsTab()) {
             Object[] tab = (Object[])ck.GetAttribute(Chunk.TAB);
             float tabPosition = (float)tab[1];
             bool newLine = (bool)tab[2];
             if (newLine && tabPosition < originalWidth - width) {
                 return new PdfLine(0, originalWidth, width, alignment, true, CreateArrayOfPdfChunks(oldCurrentChar, currentChar - 1), isRTL);
             }
             detailChunks[currentChar].AdjustLeft(leftX);
             width = originalWidth - tabPosition;
         }
     }
     if (lastValidChunk == null) {
         // not even a single char fit; must output the first char
         ++currentChar;
         if (surrogate)
             ++currentChar;
         return new PdfLine(0, originalWidth, 0, alignment, false, CreateArrayOfPdfChunks(currentChar - 1, currentChar - 1), isRTL);
     }
     if (currentChar >= totalTextLength) {
         // there was more line than text
         return new PdfLine(0, originalWidth, width, alignment, true, CreateArrayOfPdfChunks(oldCurrentChar, totalTextLength - 1), isRTL);
     }
     int newCurrentChar = TrimRightEx(oldCurrentChar, currentChar - 1);
     if (newCurrentChar < oldCurrentChar) {
         // only WS
         return new PdfLine(0, originalWidth, width, alignment, false, CreateArrayOfPdfChunks(oldCurrentChar, currentChar - 1), isRTL);
     }
     if (newCurrentChar == currentChar - 1) { // middle of word
         IHyphenationEvent he = (IHyphenationEvent)lastValidChunk.GetAttribute(Chunk.HYPHENATION);
         if (he != null) {
             int[] word = GetWord(oldCurrentChar, newCurrentChar);
             if (word != null) {
                 float testWidth = width + GetWidth(word[0], currentChar - 1);
                 String pre = he.GetHyphenatedWordPre(new String(text, word[0], word[1] - word[0]), lastValidChunk.Font.Font, lastValidChunk.Font.Size, testWidth);
                 String post = he.HyphenatedWordPost;
                 if (pre.Length > 0) {
                     PdfChunk extra = new PdfChunk(pre, lastValidChunk);
                     currentChar = word[1] - post.Length;
                     return new PdfLine(0, originalWidth, testWidth - lastValidChunk.Font.Width(pre), alignment, false, CreateArrayOfPdfChunks(oldCurrentChar, word[0] - 1, extra), isRTL);
                 }
             }
         }
     }
     if (lastSplit == -1 || lastSplit >= newCurrentChar) {
         // no split point or split point ahead of end
         return new PdfLine(0, originalWidth, width + GetWidth(newCurrentChar + 1, currentChar - 1), alignment, false, CreateArrayOfPdfChunks(oldCurrentChar, newCurrentChar), isRTL);
     }
     // standard split
     currentChar = lastSplit + 1;
//.........这里部分代码省略.........
开发者ID:bmictech,项目名称:iTextSharp,代码行数:101,代码来源:BidiLine.cs


示例9: AddPiece

 public void AddPiece(char c, PdfChunk chunk)
 {
     if (totalTextLength >= pieceSize) {
         char[] tempText = text;
         PdfChunk[] tempDetailChunks = detailChunks;
         pieceSize *= 2;
         text = new char[pieceSize];
         detailChunks = new PdfChunk[pieceSize];
         Array.Copy(tempText, 0, text, 0, totalTextLength);
         Array.Copy(tempDetailChunks, 0, detailChunks, 0, totalTextLength);
     }
     text[totalTextLength] = c;
     detailChunks[totalTextLength++] = chunk;
 }
开发者ID:bmictech,项目名称:iTextSharp,代码行数:14,代码来源:BidiLine.cs


示例10: AddToLine

 private void AddToLine(PdfChunk chunk)
 {
     if (chunk.ChangeLeading && chunk.IsImage()) {
         Image img = chunk.Image;
         float f = img.ScaledHeight + chunk.ImageOffsetY
             + img.BorderWidthTop + img.SpacingBefore;
         if (f > height) height = f;
     }
     line.Add(chunk);
 }
开发者ID:karino2,项目名称:wikipediaconv,代码行数:10,代码来源:PdfLine.cs


示例11: Add

        // methods
    
        /**
         * Adds a <CODE>PdfChunk</CODE> to the <CODE>PdfLine</CODE>.
         *
         * @param		chunk		        the <CODE>PdfChunk</CODE> to add
         * @param		currentLeading		new value for the height of the line
         * @return		<CODE>null</CODE> if the chunk could be added completely; if not
         *				a <CODE>PdfChunk</CODE> containing the part of the chunk that could
         *				not be added is returned
         */

        internal PdfChunk Add(PdfChunk chunk, float currentLeading) {
            //we set line height to correspond to the current leading
            if (chunk != null && !chunk.ToString().Equals("")) {
                //whitespace shouldn't change leading
                if (!chunk.ToString().Equals(" ")) {
                    if (this.height < currentLeading || this.line.Count == 0)
                        this.height = currentLeading;
                }
            }
            return Add(chunk);
        }
开发者ID:joshaxey,项目名称:Simple-PDFMerge,代码行数:23,代码来源:PdfLine.cs


示例12: AddToLine

 private void AddToLine(PdfChunk chunk) {
     if (chunk.ChangeLeading && chunk.IsImage()) {
         float f = chunk.Image.ScaledHeight + chunk.ImageOffsetY + chunk.Image.BorderWidthTop;
         if (f > height) height = f;
     }
     line.Add(chunk);
 }
开发者ID:,项目名称:,代码行数:7,代码来源:


示例13: 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


示例14: 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


示例15: IsSplitCharacter

 /**
 * Checks if a character can be used to split a <CODE>PdfString</CODE>.
 * <P>
 * for the moment every character less than or equal to SPACE and the character '-' are 'splitCharacters'.
 *
 * @param start start position in the array
 * @param current current position in the array
 * @param end end position in the array
 * @param    cc        the character array that has to be checked
 * @param ck chunk array
 * @return    <CODE>true</CODE> if the character can be used to split a string, <CODE>false</CODE> otherwise
 */
 public bool IsSplitCharacter(int start, int current, int end, char[] cc, PdfChunk[] ck)
 {
     char c;
     if (ck == null)
         c = cc[current];
     else
         c = ck[Math.Min(current, ck.Length - 1)].GetUnicodeEquivalent(cc[current]);
     if (c <= ' ' || c == '-') {
         return true;
     }
     if (c < 0x2e80)
         return false;
     return ((c >= 0x2e80 && c < 0xd7a0)
         || (c >= 0xf900 && c < 0xfb00)
         || (c >= 0xfe30 && c < 0xfe50)
         || (c >= 0xff61 && c < 0xffa0));
 }
开发者ID:hjgode,项目名称:iTextSharpCF,代码行数:29,代码来源:PdfChunk.cs


示例16: Add

        // methods
        /**
         * Adds a <CODE>PdfChunk</CODE> to the <CODE>PdfLine</CODE>.
         *
         * @param        chunk        the <CODE>PdfChunk</CODE> to add
         * @return        <CODE>null</CODE> if the chunk could be added completely; if not
         *                a <CODE>PdfChunk</CODE> containing the part of the chunk that could
         *                not be added is returned
         */
        internal PdfChunk Add(PdfChunk chunk)
        {
            // nothing happens if the chunk is null.
            if (chunk == null || chunk.ToString().Equals("")) {
                return null;
            }

            // we split the chunk to be added
            PdfChunk overflow = chunk.Split(width);
            newlineSplit = (chunk.IsNewlineSplit() || overflow == null);
            //        if (chunk.IsNewlineSplit() && alignment == Element.ALIGN_JUSTIFIED)
            //            alignment = Element.ALIGN_LEFT;

            // if the length of the chunk > 0 we add it to the line
            if (chunk.Length > 0) {
                if (overflow != null)
                    chunk.TrimLastSpace();
                width -= chunk.Width;
                AddToLine(chunk);
            }

                // if the length == 0 and there were no other chunks added to the line yet,
                // we risk to end up in an endless loop trying endlessly to add the same chunk
            else if (line.Count < 1) {
                chunk = overflow;
                overflow = chunk.Truncate(width);
                width -= chunk.Width;
                if (chunk.Length > 0) {
                    AddToLine(chunk);
                    return overflow;
                }
                    // if the chunck couldn't even be truncated, we add everything, so be it
                else {
                    if (overflow != null)
                        AddToLine(chunk);
                    return null;
                }
            }
            else {
                width += ((PdfChunk)(line[line.Count - 1])).TrimLastSpace();
            }
            return overflow;
        }
开发者ID:hjgode,项目名称:iTextSharpCF,代码行数:52,代码来源:PdfLine.cs


示例17: Add

        // methods
        /**
         * Adds a <CODE>PdfChunk</CODE> to the <CODE>PdfLine</CODE>.
         *
         * @param        chunk        the <CODE>PdfChunk</CODE> to add
         * @return        <CODE>null</CODE> if the chunk could be added completely; if not
         *                a <CODE>PdfChunk</CODE> containing the part of the chunk that could
         *                not be added is returned
         */
        internal PdfChunk Add(PdfChunk chunk)
        {
            // nothing happens if the chunk is null.
            if (chunk == null || chunk.ToString().Equals("")) {
                return null;
            }

            // we split the chunk to be added
            PdfChunk overflow = chunk.Split(width);
            newlineSplit = (chunk.IsNewlineSplit() || overflow == null);
            //        if (chunk.IsNewlineSplit() && alignment == Element.ALIGN_JUSTIFIED)
            //            alignment = Element.ALIGN_LEFT;
            if (chunk.IsTab()) {
                Object[] tab = (Object[])chunk.GetAttribute(Chunk.TAB);
                float tabPosition = (float)tab[1];
                bool newline = (bool)tab[2];
                if (newline && tabPosition < originalWidth - width) {
                    return chunk;
                }
                width = originalWidth - tabPosition;
                chunk.AdjustLeft(left);
                AddToLine(chunk);
            }
            // if the length of the chunk > 0 we add it to the line
            else if (chunk.Length > 0 || chunk.IsImage()) {
                if (overflow != null)
                    chunk.TrimLastSpace();
                width -= chunk.Width;
                AddToLine(chunk);
            }

                // if the length == 0 and there were no other chunks added to the line yet,
                // we risk to end up in an endless loop trying endlessly to add the same chunk
            else if (line.Count < 1) {
                chunk = overflow;
                overflow = chunk.Truncate(width);
                width -= chunk.Width;
                if (chunk.Length > 0) {
                    AddToLine(chunk);
                    return overflow;
                }
                    // if the chunck couldn't even be truncated, we add everything, so be it
                else {
                    if (overflow != null)
                        AddToLine(chunk);
                    return null;
                }
            }
            else {
                width += ((PdfChunk)(line[line.Count - 1])).TrimLastSpace();
            }
            return overflow;
        }
开发者ID:karino2,项目名称:wikipediaconv,代码行数:62,代码来源:PdfLine.cs


示例18: AddChunk

 public void AddChunk(PdfChunk chunk)
 {
     chunks.Add(chunk);
 }
开发者ID:bmictech,项目名称:iTextSharp,代码行数:4,代码来源:BidiLine.cs


示例19: AddToLine

 private void AddToLine(PdfChunk chunk) {
     if (chunk.ChangeLeading) {
         float f;
         if (chunk.IsImage()) {
             Image img = chunk.Image;
             f = chunk.ImageHeight + chunk.ImageOffsetY
                     + img.BorderWidthTop + img.SpacingBefore;
         } else {
             f = chunk.Leading;
         }
         if (f > height) height = f;
     }
     if (tabStop != null && tabStop.Align == TabStop.Alignment.ANCHOR && float.IsNaN(tabStopAnchorPosition))
     {
         String value = chunk.ToString();
         int anchorIndex = value.IndexOf(tabStop.AnchorChar);
         if (anchorIndex != -1)
         {
             float subWidth = chunk.Width(value.Substring(anchorIndex));
             tabStopAnchorPosition = originalWidth - width - subWidth;
         }
     }
     line.Add(chunk);
 }
开发者ID:joshaxey,项目名称:Simple-PDFMerge,代码行数:24,代码来源:PdfLine.cs


示例20: CreateArrayOfPdfChunks

 public ArrayList CreateArrayOfPdfChunks(int startIdx, int endIdx, PdfChunk extraPdfChunk)
 {
     bool bidi = (runDirection == PdfWriter.RUN_DIRECTION_LTR || runDirection == PdfWriter.RUN_DIRECTION_RTL);
     if (bidi)
         Reorder(startIdx, endIdx);
     ArrayList ar = new ArrayList();
     PdfChunk refCk = detailChunks[startIdx];
     PdfChunk ck = null;
     StringBuilder buf = new StringBuilder();
     char c;
     int idx = 0;
     for (; startIdx <= endIdx; ++startIdx) {
         idx = bidi ? indexChars[startIdx] : startIdx;
         c = text[idx];
         ck = detailChunks[idx];
         if (PdfChunk.NoPrint(ck.GetUnicodeEquivalent(c)))
             continue;
         if (ck.IsImage() || ck.IsSeparator() || ck.IsTab()) {
             if (buf.Length > 0) {
                 ar.Add(new PdfChunk(buf.ToString(), refCk));
                 buf = new StringBuilder();
             }
             ar.Add(ck);
         }
         else if (ck == refCk) {
             buf.Append(c);
         }
         else {
             if (buf.Length > 0) {
                 ar.Add(new PdfChunk(buf.ToString(), refCk));
                 buf = new StringBuilder();
             }
             if (!ck.IsImage() && !ck.IsSeparator() && !ck.IsTab())
                 buf.Append(c);
             refCk = ck;
         }
  

鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
C# pdf.PdfContentByte类代码示例发布时间:2022-05-26
下一篇:
C# pdf.PdfArray类代码示例发布时间: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