PDFsharp - moved to http://forum.pdfsharp.net/ Forum Index PDFsharp - moved to http://forum.pdfsharp.net/
Please visit the new PDFsharp forum at http://forum.pdfsharp.net/
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Table of Contents

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    PDFsharp - moved to http://forum.pdfsharp.net/ Forum Index -> Support - moved to http://forum.pdfsharp.net/
View previous topic :: View next topic  
Author Message
woany



Joined: 10 Dec 2008
Posts: 2

PostPosted: Wed Dec 10, 2008 3:43 pm    Post subject: Table of Contents Reply with quote

I am trying to get a table of contents working, I've looked at the example in the HelloMigraDoc example.

The bookmark tree is generated correctly but when you click on the bookmark entry (in the treeview), the document does not go to the page clicked.

My simple example code is below:

Code:
Document document = new Document();

Section sectionToc = document.AddSection();

Section section = document.AddSection();
Paragraph paragraph = section.AddParagraph("PARA1");
paragraph.AddBookmark("SECTION1");

section = document.AddSection();
paragraph = section.AddParagraph("PARA2");
paragraph.AddBookmark("SECTION2");

paragraph = sectionToc.AddParagraph();
paragraph.Format.OutlineLevel = OutlineLevel.Level1;

Hyperlink hyperlink = paragraph.AddHyperlink("SECTION1");
hyperlink.AddText("SECTION1\t");
hyperlink.AddPageRefField("SECTION1");

paragraph = sectionToc.AddParagraph();
paragraph.Format.OutlineLevel = OutlineLevel.Level2;

hyperlink = paragraph.AddHyperlink("SECTION2");
hyperlink.AddText("SECTION2\t");
hyperlink.AddPageRefField("SECTION2");

PdfDocumentRenderer pdfRenderer = new PdfDocumentRenderer(true);

pdfRenderer.Document = document;
pdfRenderer.RenderDocument();

pdfRenderer.Save("test.pdf");

Process.Start("test.pdf");

Can anyone see what i am doing wrong?

Many thanks
Back to top
View user's profile Send private message
Thomas Hoevel



Joined: 16 Oct 2006
Posts: 387
Location: Cologne, Germany

PostPosted: Thu Dec 11, 2008 9:03 am    Post subject: Reply with quote

The bookmark tree is created from the paragraphs with outline level.
They are all on the TOC page in your sample ...

Set the outline level where you add the bookmarks!

BTW: bookmarks are only strings. You can add references to the TOC before adding the bookmarks to the document.

The predefined styles Heading1, Heading2, ... have the appropriate outline level. You don't have to set the outline level of a paragraph if you set the style of the paragraph.
_________________
Regards
Thomas Hoevel
PDFsharp Team
Back to top
View user's profile Send private message Visit poster's website
woany



Joined: 10 Dec 2008
Posts: 2

PostPosted: Thu Dec 11, 2008 12:45 pm    Post subject: Ah Reply with quote

Ah, so thats how it works! Thanks for the quick response. Excellent library by the way.
Back to top
View user's profile Send private message
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    PDFsharp - moved to http://forum.pdfsharp.net/ Forum Index -> Support - moved to http://forum.pdfsharp.net/ All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © phpBB Group. Hosted by phpBB.BizHat.com


Start Your Own YouTube Clone

Free Web Hosting | Free Forum Hosting | FlashWebHost.com | Image Hosting | Photo Gallery | FreeMarriage.com

Powered by PhpBBweb.com, setup your forum now!
For Support, visit Forums.BizHat.com