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


C# pdf.PdfOutline類代碼示例

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


PdfOutline類屬於iTextSharp.text.pdf命名空間,在下文中一共展示了PdfOutline類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: CreatePdf

 // ---------------------------------------------------------------------------    
 /**
  * Creates a PDF document.
  */
 public byte[] CreatePdf()
 {
     using (MemoryStream ms = new MemoryStream())
     {
         // step 1
         using (Document document = new Document())
         {
             // step 2
             PdfWriter writer = PdfWriter.GetInstance(document, ms);
             // step 3
             document.Open();
             // step 4
             PdfOutline root = writer.RootOutline;
             PdfOutline movieBookmark;
             PdfOutline link;
             String title;
             IEnumerable<Movie> movies = PojoFactory.GetMovies();
             foreach (Movie movie in movies)
             {
                 title = movie.MovieTitle;
                 if ("3-Iron".Equals(title))
                     title = "\ube48\uc9d1";
                 movieBookmark = new PdfOutline(root,
                   new PdfDestination(
                     PdfDestination.FITH, writer.GetVerticalPosition(true)
                   ),
                   title, true
                 );
                 movieBookmark.Style = Font.BOLD;
                 link = new PdfOutline(movieBookmark,
                   new PdfAction(String.Format(RESOURCE, movie.Imdb)),
                   "link to IMDB"
                 );
                 link.Color = BaseColor.BLUE;
                 new PdfOutline(movieBookmark,
                   PdfAction.JavaScript(
                     String.Format(INFO, movie.Year, movie.Duration),
                     writer
                   ),
                   "instant info"
                 );
                 document.Add(new Paragraph(movie.MovieTitle));
                 document.Add(PojoToElementFactory.GetDirectorList(movie));
                 document.Add(PojoToElementFactory.GetCountryList(movie));
             }
         }
         return ms.ToArray();
     }
 }
開發者ID:kuujinbo,項目名稱:iTextInAction2Ed,代碼行數:53,代碼來源:CreateOutlineTree.cs

示例2: PdfOutline

 /**
  * Constructs a <CODE>PdfOutline</CODE>.
  * <P>
  * This is the constructor for an <CODE>outline entry</CODE>. The open mode is
  * <CODE>true</CODE>.
  *
  * @param parent the parent of this outline item
  * @param destination the destination for this outline item
  * @param title the title of this outline item
  */
 public PdfOutline(PdfOutline parent, PdfDestination destination, PdfString title)
     : this(parent, destination, title, true)
 {
 }
開發者ID:medvedttn,項目名稱:itextsharp_mod-src,代碼行數:14,代碼來源:PdfOutline.cs

示例3: CreatePdfOutline

 private PdfOutline CreatePdfOutline(PdfOutline parent, Bookmark bookmark)
 {
     return new PdfOutline(parent, PdfAction.GotoLocalPage(bookmark.PageNumber, new PdfDestination(bookmark.PageNumber), _writer), bookmark.Title);
 }
開發者ID:marcostomazini,項目名稱:ReleaseNotes,代碼行數:4,代碼來源:ReleaseNotesPdfWriter.cs

示例4: Add


//.........這裏部分代碼省略.........
                    CarriageReturn();
                    tabSettings = backupTabSettings;
                    PopLeading();
                    if (IsTagged(writer))
                    {
                        FlushLines();
                        text.CloseMCBlock(paragraph);
                    }
                    break;
                }
                case Element.SECTION:
                case Element.CHAPTER: {
                    // Chapters and Sections only differ in their constructor
                    // so we cast both to a Section
                    Section section = (Section) element;
                    IPdfPageEvent pageEvent = writer.PageEvent;
                    
                    bool hasTitle = section.NotAddedYet && section.Title != null;
                    
                    // if the section is a chapter, we begin a new page
                    if (section.TriggerNewPage) {
                        NewPage();
                    }

                    if (hasTitle) {
                        float fith = IndentTop - currentHeight;
                        int rotation = pageSize.Rotation;
                        if (rotation == 90 || rotation == 180)
                            fith = pageSize.Height - fith;
                        PdfDestination destination = new PdfDestination(PdfDestination.FITH, fith);
                        while (currentOutline.Level >= section.Depth) {
                            currentOutline = currentOutline.Parent;
                        }
                        PdfOutline outline = new PdfOutline(currentOutline, destination, section.GetBookmarkTitle(), section.BookmarkOpen);
                        currentOutline = outline;
                    }
                    
                    // some values are set
                    CarriageReturn();
                    indentation.sectionIndentLeft += section.IndentationLeft;
                    indentation.sectionIndentRight += section.IndentationRight;                    
                    if (section.NotAddedYet && pageEvent != null)
                        if (element.Type == Element.CHAPTER)
                            pageEvent.OnChapter(writer, this, IndentTop - currentHeight, section.Title);
                        else
                            pageEvent.OnSection(writer, this, IndentTop - currentHeight, section.Depth, section.Title);
                    
                    // the title of the section (if any has to be printed)
                    if (hasTitle) {
                        isSectionTitle = true;
                        Add(section.Title);
                        isSectionTitle = false;
                    }
                    indentation.sectionIndentLeft += section.Indentation;
                    // we process the section
                    element.Process(this);
                    // some parameters are set back to normal again
                    indentation.sectionIndentLeft -= (section.IndentationLeft + section.Indentation);
                    indentation.sectionIndentRight -= section.IndentationRight;
                    
                    if (section.ElementComplete && pageEvent != null)
                        if (element.Type == Element.CHAPTER)
                            pageEvent.OnChapterEnd(writer, this, IndentTop - currentHeight);
                        else
                            pageEvent.OnSectionEnd(writer, this, IndentTop - currentHeight);
                    
開發者ID:NelsonSantos,項目名稱:fyiReporting-Android,代碼行數:66,代碼來源:PdfDocument.cs

示例5: TraverseOutlineCount

 internal void TraverseOutlineCount(PdfOutline outline) {
     List<PdfOutline> kids = outline.Kids;
     PdfOutline parent = outline.Parent;
     if (kids.Count == 0) {
         if (parent != null) {
             parent.Count = parent.Count + 1;
         }
     }
     else {
         for (int k = 0; k < kids.Count; ++k) {
             TraverseOutlineCount(kids[k]);
         }
         if (parent != null) {
             if (outline.Open) {
                 parent.Count = outline.Count + parent.Count + 1;
             }
             else {
                 parent.Count = parent.Count + 1;
                 outline.Count = -outline.Count;
             }
         }
     }
 }
開發者ID:NelsonSantos,項目名稱:fyiReporting-Android,代碼行數:23,代碼來源:PdfDocument.cs

示例6: InitOutline

 // methods
 /** Helper for the constructors.
  * @param parent the parent outline
  * @param title the title for this outline
  * @param open <CODE>true</CODE> if the children are visible
  */
 internal void InitOutline(PdfOutline parent, string title, bool open)
 {
     this.open = open;
     this.parent = parent;
     writer = parent.writer;
     Put(PdfName.TITLE, new PdfString(title, PdfObject.TEXT_UNICODE));
     parent.AddKid(this);
     if (destination != null && !destination.HasPage()) // bugfix Finn Bock
         SetDestinationPage(writer.CurrentPage);
 }
開發者ID:medvedttn,項目名稱:itextsharp_mod-src,代碼行數:16,代碼來源:PdfOutline.cs

示例7: GenerateTo

        public void GenerateTo(PdfOutline parentOutline)
        {
            if (_currentNode == null) return;

            var startNode = Root.FirstChild();
            Visit(parentOutline, startNode);
        }
開發者ID:karak,項目名稱:Geovanni,代碼行數:7,代碼來源:PdfOutlineBuilder.cs

示例8: Visit

        private void Visit(PdfOutline parentOutline, OutlineNode node)
        {
            if (node == null) return;
            var counterString = Path(node);
            var thisOutline = new PdfOutline(parentOutline, PdfAction.GotoLocalPage(counterString, false), node.Title.ToString());

            Visit(thisOutline, node.FirstChild());
            Visit(parentOutline, node.NextSibling());
        }
開發者ID:karak,項目名稱:Geovanni,代碼行數:9,代碼來源:PdfOutlineBuilder.cs

示例9: AddBookContents

 public void AddBookContents(PdfWriter writer, PdfOutline outline, BookContentNode content)
 {
     foreach (BookContentNode contentnode in content.Children)
     {
         int page = contentnode.Bookcontent.Page;
         if (page > _book.PagesNum)
             break;
         page += _frontpagesinfo.DownloadedPages;
         PdfAction action = PdfAction.GotoLocalPage(page, new PdfDestination(PdfDestination.FITB), writer);
         AddBookContents(writer, new PdfOutline(outline, action, contentnode.Bookcontent.Title), contentnode);
     }
 }
開發者ID:leicheng1996,項目名稱:eReading,代碼行數:12,代碼來源:Download.cs

示例10: HeaderNode

 /**
  * Constructor.
  * @param level the level
  * @param outline the PdfOutline for this HeaderNode
  * @param parent the parent HeaderNode
  * 
  */
 public HeaderNode(int level, PdfOutline outline, HeaderNode parent) {
     this.level = level;
     this.outline = outline;
     this.parent = parent;
 }
開發者ID:jagruti23,項目名稱:itextsharp,代碼行數:12,代碼來源:HeaderNode.cs

示例11: Add


//.........這裏部分代碼省略.........

                    alignment = Element.ALIGN_LEFT;
                    indentLeft -= paragraph.IndentationLeft;
                    indentRight -= paragraph.IndentationRight;
                    CarriageReturn();
                    break;
                }
                case Element.SECTION:
                case Element.CHAPTER: {
                    // Chapters and Sections only differ in their constructor
                    // so we cast both to a Section
                    Section section = (Section) element;

                    bool hasTitle = section.Title != null;

                    // if the section is a chapter, we begin a new page
                    if (section.TriggerNewPage) {
                        NewPage();
                    }
                    // otherwise, we begin a new line
                    else {
                        NewLine();
                    }

                    if (hasTitle) {
                    float fith = IndentTop - currentHeight;
                    int rotation = pageSize.Rotation;
                    if (rotation == 90 || rotation == 180)
                        fith = pageSize.Height - fith;
                    PdfDestination destination = new PdfDestination(PdfDestination.FITH, fith);
                    while (currentOutline.Level >= section.Depth) {
                        currentOutline = currentOutline.Parent;
                    }
                    PdfOutline outline = new PdfOutline(currentOutline, destination, section.GetBookmarkTitle(), section.BookmarkOpen);
                    currentOutline = outline;
                    }

                    // some values are set
                    CarriageReturn();
                    indentLeft += section.IndentationLeft;
                    indentRight += section.IndentationRight;
                    sectionIndentL += section.IndentationLeft;
                    sectionIndentR += section.IndentationRight;
                    IPdfPageEvent pageEvent = writer.PageEvent;
                    if (pageEvent != null)
                        if (element.Type == Element.CHAPTER)
                            pageEvent.OnChapter(writer, this, IndentTop - currentHeight, section.Title);
                        else
                            pageEvent.OnSection(writer, this, IndentTop - currentHeight, section.Depth, section.Title);

                    // the title of the section (if any has to be printed)
                    if (hasTitle) {
                        isParagraph = false;
                        Add(section.Title);
                        isParagraph = true;
                    }
                    indentLeft += section.Indentation;
                    sectionIndentL += section.Indentation;
                    // we process the section
                    element.Process(this);
                    // some parameters are set back to normal again
                    indentLeft -= section.IndentationLeft + section.Indentation;
                    indentRight -= section.IndentationRight;
                    sectionIndentL -= section.IndentationLeft + section.Indentation;
                    sectionIndentR -= section.IndentationRight;
開發者ID:hjgode,項目名稱:iTextSharpCF,代碼行數:66,代碼來源:PdfDocument.cs

示例12: AddOutline

 /**
  * Adds a named outline to the document.
  *
  * @param outline the outline
  * @param name the name for the local destination
  */
 public void AddOutline(PdfOutline outline, string name)
 {
     CheckWriter();
     pdf.AddOutline(outline, name);
 }
開發者ID:HardcoreSoftware,項目名稱:iSecretary,代碼行數:11,代碼來源:PdfContentByte.cs

示例13: AddKid

 public void AddKid(PdfOutline outline)
 {
     kids.Add(outline);
 }
開發者ID:medvedttn,項目名稱:itextsharp_mod-src,代碼行數:4,代碼來源:PdfOutline.cs

示例14: AddOutline

 /**
 * Adds a named outline to the document .
 * @param outline the outline to be added
 * @param name the name of this local destination
 */
 internal void AddOutline(PdfOutline outline, String name) {
     LocalDestination(name, outline.PdfDestination);
 }
開發者ID:NelsonSantos,項目名稱:fyiReporting-Android,代碼行數:8,代碼來源:PdfDocument.cs

示例15: OutlineTree

 internal void OutlineTree(PdfOutline outline) {
     outline.IndirectReference = writer.PdfIndirectReference;
     if (outline.Parent != null)
         outline.Put(PdfName.PARENT, outline.Parent.IndirectReference);
     List<PdfOutline> kids = outline.Kids;
     int size = kids.Count;
     for (int k = 0; k < size; ++k)
         OutlineTree(kids[k]);
     for (int k = 0; k < size; ++k) {
         if (k > 0)
             kids[k].Put(PdfName.PREV, kids[k - 1].IndirectReference);
         if (k < size - 1)
             kids[k].Put(PdfName.NEXT, kids[k + 1].IndirectReference);
     }
     if (size > 0) {
         outline.Put(PdfName.FIRST, kids[0].IndirectReference);
         outline.Put(PdfName.LAST, kids[size - 1].IndirectReference);
     }
     for (int k = 0; k < size; ++k) {
         PdfOutline kid = kids[k];
         writer.AddToBody(kid, kid.IndirectReference);
     }
 }
開發者ID:NelsonSantos,項目名稱:fyiReporting-Android,代碼行數:23,代碼來源:PdfDocument.cs


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