PDFsharp & MigraDoc Foundation
http://forum.pdfsharp.de/

Urgent! How to create index with PdfSharp
http://forum.pdfsharp.de/viewtopic.php?f=2&t=895
Page 1 of 1

Author:  lexyland [ Thu Oct 01, 2009 7:43 am ]
Post subject:  Urgent! How to create index with PdfSharp

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!

Author:  Thomas Hoevel [ Thu Oct 01, 2009 7:55 am ]
Post subject:  Re: Urgent! How to create index with PdfSharp

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.

Author:  lexyland [ Thu Oct 01, 2009 9:01 am ]
Post subject:  Re: Urgent! How to create index with PdfSharp

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!

Author:  Thomas Hoevel [ Thu Oct 01, 2009 9:30 am ]
Post subject:  Re: Urgent! How to create index with PdfSharp

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.

Author:  lexyland [ Thu Oct 01, 2009 9:37 am ]
Post subject:  Re: Urgent! How to create index with PdfSharp

Thank you, I will try that!

Author:  lexyland [ Thu Oct 01, 2009 11:56 pm ]
Post subject:  Re: Urgent! How to create index with PdfSharp

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);

Author:  lexyland [ Fri Oct 02, 2009 2:37 am ]
Post subject:  Re: Urgent! How to create index with PdfSharp

I have sovled the problem, thank you for your help

Page 1 of 1 All times are UTC
Powered by phpBB® Forum Software © phpBB Group
https://www.phpbb.com/