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


C# PdfChunk.IsNewlineSplit方法代碼示例

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


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

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

示例2: Add

            /**
             * 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);
                if (chunk.IsAttribute(Chunk.TABSETTINGS)) {
                    bool isWhiteSpace = (bool) tab[1];
                    if (!isWhiteSpace || line.Count > 0) {
                        Flush();
                        tabStopAnchorPosition = float.NaN;
                        tabStop = PdfChunk.GetTabStop(chunk, originalWidth - width);
                        if (tabStop.Position > originalWidth) {
                            if (isWhiteSpace)
                                overflow = null;
                            else if (Math.Abs(originalWidth - width) < 0.001) {
                                AddToLine(chunk);
                                overflow = null;
                            } else {
                                overflow = chunk;
                            }
							width = 0;
                        } else {
                            chunk.TabStop = tabStop;
                            if (!isRTL && tabStop.Align == TabStop.Alignment.LEFT) {
                                width = originalWidth - tabStop.Position;
                                tabStop = null;
                                tabPosition = float.NaN;
                            } else
                                tabPosition = originalWidth - width;
                            AddToLine(chunk);
                        }
                    } else
                        return null;
                } else {
                    //Keep deprecated tab logic for backward compatibility...
                    float tabStopPosition = (float) tab[1];
                    bool newline = (bool) tab[2];
                    if (newline && tabStopPosition < originalWidth - width)
                        return chunk;
                    chunk.AdjustLeft(left);
                    width = originalWidth - tabStopPosition;
                    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 += line[line.Count - 1].TrimLastSpace();
            }
            return overflow;
        }
開發者ID:joshaxey,項目名稱:Simple-PDFMerge,代碼行數:90,代碼來源:PdfLine.cs

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

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


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