PDFsharp & MigraDoc Foundation https://forum.pdfsharp.net/ |
|
Table of content is not aligned properly https://forum.pdfsharp.net/viewtopic.php?f=2&t=1177 |
Page 1 of 1 |
Author: | pesantsi [ Mon May 10, 2010 6:37 pm ] | ||
Post subject: | Table of content is not aligned properly | ||
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); } } }
|
Author: | Thomas Hoevel [ Tue May 11, 2010 7:16 am ] |
Post subject: | Re: Table of content is not aligned properly |
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? |
Author: | pesantsi [ Tue May 11, 2010 1:11 pm ] |
Post subject: | Re: Table of content is not aligned properly |
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"; |
Author: | Thomas Hoevel [ Tue May 11, 2010 2:11 pm ] |
Post subject: | Re: Table of content is not aligned properly |
If you give me a MDDDL file of that TOC I'll take a look at it. http://www.pdfsharp.net/wiki/MigraDocDDL.ashx |
Author: | pesantsi [ Tue May 11, 2010 2:38 pm ] | ||
Post subject: | Re: Table of content is not aligned properly | ||
Here is the file
|
Author: | Thomas Hoevel [ Tue May 11, 2010 2:55 pm ] |
Post subject: | Re: Table of content is not aligned properly |
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. |
Author: | pesantsi [ Tue May 11, 2010 6:59 pm ] | ||
Post subject: | Re: Table of content is not aligned properly | ||
here
|
Author: | Thomas Hoevel [ Wed May 12, 2010 7:44 am ] |
Post subject: | Re: Table of content is not aligned properly |
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. |
Page 1 of 1 | All times are UTC |
Powered by phpBB® Forum Software © phpBB Group https://www.phpbb.com/ |