PDFsharp & MigraDoc Foundation

PDFsharp - A .NET library for processing PDF & MigraDoc Foundation - Creating documents on the fly
It is currently Sun Apr 28, 2024 1:54 am

All times are UTC


Forum rules


Please read this before posting on this forum: Forum Rules



Post new topic Reply to topic  [ 7 posts ] 
Author Message
PostPosted: Thu Oct 01, 2009 7:43 am 
Offline

Joined: Thu Oct 01, 2009 7:23 am
Posts: 7
Hi, I am doing a project creating pdf file using PdfSharp.
But I do not know how to create index (Like Table of Contents in the Hello MigraDoc Sample), Because I have done most of the work in PdfSharp, and I have some problem using the mix example(the index does not direct to the correct page when inserting into the Pdfsharp document).
Is there any way to create index in PdfSharp? Please Help me!


Top
 Profile  
Reply with quote  
PostPosted: Thu Oct 01, 2009 7:55 am 
Offline
PDFsharp Guru
User avatar

Joined: Mon Oct 16, 2006 8:16 am
Posts: 3096
Location: Cologne, Germany
Hi!

Yes, it can be done.

lexyland wrote:
the index does not direct to the correct page when inserting into the Pdfsharp document

What's wrong? Is it an Obiwan Error?
IIRC pages are 0-based in PDFsharp. So if you print "Page 1" you actually have to jump to page 0.

_________________
Regards
Thomas Hoevel
PDFsharp Team


Top
 Profile  
Reply with quote  
PostPosted: Thu Oct 01, 2009 9:01 am 
Offline

Joined: Thu Oct 01, 2009 7:23 am
Posts: 7
Maybe sth wrong with the loop! But the major issue is I cannot use MigraDoc anymore,
Because I have already created the pdf document with PDFsharp, All I want to to is to index the some of the content(just first page of each section).
And the content is dynamicallly generated based on input object.
So using some method in PDFsharp is much easier. Can you provide me some method? Because there is not any in the examples, and the I found nothing when searching in the help file!


Top
 Profile  
Reply with quote  
PostPosted: Thu Oct 01, 2009 9:30 am 
Offline
PDFsharp Guru
User avatar

Joined: Mon Oct 16, 2006 8:16 am
Posts: 3096
Location: Cologne, Germany
Here's a code-snippet from MigraDoc:
Code:
page.AddDocumentLink(new PdfRectangle(rect), pageRef);

rect is the clickable region on your page, pageRef is the page number.
And page is the PdfPage that gets the link.

_________________
Regards
Thomas Hoevel
PDFsharp Team


Top
 Profile  
Reply with quote  
PostPosted: Thu Oct 01, 2009 9:37 am 
Offline

Joined: Thu Oct 01, 2009 7:23 am
Posts: 7
Thank you, I will try that!


Top
 Profile  
Reply with quote  
PostPosted: Thu Oct 01, 2009 11:56 pm 
Offline

Joined: Thu Oct 01, 2009 7:23 am
Posts: 7
HI, I have tried the
Code:
page.AddDocumentLink(new PdfRectangle(rect), pageRef);


It adds a link on the page, however, it the pageRef arguments only takes number starting from 2, but no matter how I change the pafRef argument(even from 2 ~1000), it always turns to page 4, there are 7 pages in total.
I am wondering maybe there are some errors with page referencing, or maybe I have to create sth like reference to the page?

Below is my code:

Code:
            PdfPage full = document.AddPage();
            full.Width = XUnit.FromInch(8.27);
            full.Height = XUnit.FromInch(11.69);
            gfx = XGraphics.FromPdfPage(full);
              XRect link = new XRect(new PdfSharp.Drawing.XPoint(0, 0), new PdfSharp.Drawing.XPoint(200, 200));
            PdfRectangle lin = new PdfRectangle(link);
            full.AddDocumentLink(lin,100);


Top
 Profile  
Reply with quote  
PostPosted: Fri Oct 02, 2009 2:37 am 
Offline

Joined: Thu Oct 01, 2009 7:23 am
Posts: 7
I have sovled the problem, thank you for your help


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 7 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 211 guests


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 post attachments in this forum

Search for:
Jump to:  
Privacy Policy, Data Protection Declaration, Impressum
Powered by phpBB® Forum Software © phpBB Group