PDFsharp & MigraDoc Foundation

PDFsharp - A .NET library for processing PDF & MigraDoc Foundation - Creating documents on the fly
It is currently Wed Nov 14, 2018 9:29 pm

All times are UTC

Forum rules

Please read this before posting on this forum: Forum Rules

Post new topic Reply to topic  [ 1 post ] 
Author Message
PostPosted: Sat Jan 18, 2014 10:46 am 

Joined: Sat Jan 18, 2014 10:14 am
Posts: 1
I have been using Migradoc for a few weeks now but i'm stuck..

I have to build a small application for my job in which I have to generate a simple documentation pdf from a database. Everything is working fine except for the index page.

The setup of the program is as follows:
First of, I create a dataGridView with all the rows from the database I have to export. Then I loop through this dataGridView and for each row, I add a row to a table in the pdf.
foreach (DataGridViewRow dataRow in dataGridView.Rows)
                newFolder = dataRow.Cells[4].Value.ToString();

                Row row = t.AddRow();

                row.Cells[0].VerticalAlignment = VerticalAlignment.Center;
                Paragraph para = row.Cells[1].AddParagraph();
                //adding image to this cell. long code, don't think it's necessary.
                row.Cells[2].VerticalAlignment = VerticalAlignment.Center;
                row.Cells[3].VerticalAlignment = VerticalAlignment.Center;

Now here comes the problem. The last cell of each row contains the name of the folder in which the data is stored. When the current folder of the row that is looped is different from the last row, then a bookmark needs to be added and a reference on the index page with a page number.
if (!newFolder.Equals(oldFolder) && newFolder != "")
                    Paragraph p = row.Cells[4].AddParagraph(dataRow.Cells[4].Value.ToString());
                    p.AddBookmark(dataRow.Cells[4].Value.ToString() + "bm");
                    p.Format.OutlineLevel = OutlineLevel.Level2;

                    Hyperlink hLink = indexSection.AddParagraph().AddHyperlink(dataRow.Cells[4].Value.ToString() + "bm", HyperlinkType.Bookmark);
                    hLink.AddText(" - " + dataRow.Cells[4].Value.ToString() + "\t_______________________ ");
                    hLink.AddPageRefField(dataRow.Cells[4].Value.ToString() + "bm");


When the pdf is made, there are bookmarks. On the left side in Adobe Reader I can see all the bookmarks and they point to exactly the right page. These are probably added by the paragraph itself because I'm using
p.Format.OutlineLevel = OutlineLevel.Level2;
But when i look at the index page, I can see all the bookmarks, but the page numbers all direct to the beginning of the table and so do the hyperlinks.

I assume i'm doing something wrong, but I can't figure out what.

I'd really appreciate some help!

Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 1 post ] 

All times are UTC

Who is online

Users browsing this forum: Google [Bot] and 4 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