PDFsharp & MigraDoc Foundation

PDFsharp - A .NET library for processing PDF & MigraDoc Foundation - Creating documents on the fly
It is currently Tue Jul 02, 2024 3:16 pm

All times are UTC


Forum rules


Please read this before posting on this forum: Forum Rules



Post new topic Reply to topic  [ 8 posts ] 
Author Message
PostPosted: Mon May 10, 2010 6:37 pm 
Offline

Joined: Tue May 04, 2010 8:14 pm
Posts: 9
Hi,

I created a table of content but it's not aligned properly and I've no idea what i'm doing wrong.
I attached a pic of my table of content.

Here is the code I used to create the TOC.
If you see any problem at all, please tell me.
Thanks for your help.
Simon

Paragraph paragraph = section.AddParagraph("Table des matières", StyleNames.Heading2);
paragraph.Format.OutlineLevel = OutlineLevel.Level1;

foreach (ReportGroup group1 in rootGroup.ChildGroups)
{
paragraph = section.AddParagraph();
paragraph.Style = "TOC_Level1";

Hyperlink hyperlink = paragraph.AddHyperlink(group1.Body["1_Name"] as string);
hyperlink.AddText(group1.Body["1_Title"] as string);
hyperlink.AddTab();
hyperlink.AddPageRefField(group1.Body["1_Name"] as string);

foreach (ReportGroup group2 in group1.ChildGroups)
{
if (!String.IsNullOrEmpty(group2.Body["2_Name"] as string))
{
paragraph = section.AddParagraph();
paragraph.Style = "TOC_Level2";

hyperlink = paragraph.AddHyperlink(group2.Body["2_Name"] as string);
hyperlink.AddText(group2.Body["2_Title"] as string);
hyperlink.AddTab();
hyperlink.AddPageRefField(group2.Body["2_Name"] as string);
}
}
}


Attachments:
File comment: Table of Content
TOC.jpg
TOC.jpg [ 57.54 KiB | Viewed 9778 times ]
Top
 Profile  
Reply with quote  
PostPosted: Tue May 11, 2010 7:16 am 
Offline
PDFsharp Guru
User avatar

Joined: Mon Oct 16, 2006 8:16 am
Posts: 3101
Location: Cologne, Germany
Hi, Simon!
pesantsi wrote:
If you see any problem at all, please tell me.

I don't see the code that creates TOC_Level1 and TOC_Level2.
What can I see on the screen shot? Is it one line TOC_Level1 and two lines TOC_Level2?

_________________
Regards
Thomas Hoevel
PDFsharp Team


Top
 Profile  
Reply with quote  
PostPosted: Tue May 11, 2010 1:11 pm 
Offline

Joined: Tue May 04, 2010 8:14 pm
Posts: 9
What you are seeing is 3 lines of TOC_Level1

Style style = document.Styles.AddStyle("TOC_Level1", "Normal");
style.ParagraphFormat.AddTabStop("17.8cm", TabAlignment.Right, TabLeader.Dots);
style.ParagraphFormat.Font.Size = "10";

Style style = document.Styles.AddStyle("TOC_Level2", "Normal");
style.ParagraphFormat.AddTabStop("16cm", TabAlignment.Right, TabLeader.Dots);
style.ParagraphFormat.Font.Size = "8";
style.ParagraphFormat.LeftIndent = "1.5cm";


Top
 Profile  
Reply with quote  
PostPosted: Tue May 11, 2010 2:11 pm 
Offline
PDFsharp Guru
User avatar

Joined: Mon Oct 16, 2006 8:16 am
Posts: 3101
Location: Cologne, Germany
If you give me a MDDDL file of that TOC I'll take a look at it.
http://www.pdfsharp.net/wiki/MigraDocDDL.ashx

_________________
Regards
Thomas Hoevel
PDFsharp Team


Top
 Profile  
Reply with quote  
PostPosted: Tue May 11, 2010 2:38 pm 
Offline

Joined: Tue May 04, 2010 8:14 pm
Posts: 9
Here is the file


Attachments:
File comment: TOC.mdddl
TOC.zip [1.32 KiB]
Downloaded 574 times
Top
 Profile  
Reply with quote  
PostPosted: Tue May 11, 2010 2:55 pm 
Offline
PDFsharp Guru
User avatar

Joined: Mon Oct 16, 2006 8:16 am
Posts: 3101
Location: Cologne, Germany
pesantsi wrote:
Here is the file

This file has an empty TOC.
I'm leaving now. If you post a new file I'll have a look tomorrow.

_________________
Regards
Thomas Hoevel
PDFsharp Team


Top
 Profile  
Reply with quote  
PostPosted: Tue May 11, 2010 6:59 pm 
Offline

Joined: Tue May 04, 2010 8:14 pm
Posts: 9
here


Attachments:
File comment: Toc.mdddl
TOC.zip [237.19 KiB]
Downloaded 562 times
Top
 Profile  
Reply with quote  
PostPosted: Wed May 12, 2010 7:44 am 
Offline
PDFsharp Guru
User avatar

Joined: Mon Oct 16, 2006 8:16 am
Posts: 3101
Location: Cologne, Germany
Your code should work, so there is a bug in MigraDoc.

But: the DDL files shows "Alignment = Justify" for your TOC entries (I dunno where this comes from coz it doesn't show in your snippets).

I changed it to "Alignment = Left" and everything works fine.

Both settings should yield the same result (therefore it's a bug in MigraDoc), but "Left" is the value I would have used.

I hope this helps.

_________________
Regards
Thomas Hoevel
PDFsharp Team


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

All times are UTC


Who is online

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