PDFsharp & MigraDoc Foundation http://forum.pdfsharp.de/ |
|
How to add bullet point http://forum.pdfsharp.de/viewtopic.php?f=2&t=581 |
Page 1 of 1 |
Author: | max1001 [ Tue Dec 16, 2008 2:47 pm ] |
Post subject: | How to add bullet point |
How do I add a bullet point to a paragraph? An example code will be greatly appreciated. I search for forum for example and came up with none. |
Author: | fuzzylintman [ Tue Mar 31, 2009 9:25 pm ] |
Post subject: | Re: How to add bullet point |
max1001 wrote: How do I add a bullet point to a paragraph? An example code will be greatly appreciated. I search for forum for example and came up with none.
I'm no expert, so this may not be the only answer, but I have added bullet points as part of the text... For example: Code: AddParagraph(sec, "• Other Comments", true, ParagraphAlignment.Left, 12);
(Note that the 'AddParagraph' function is a separate method, not a PDFSharp/MigraDoc function, but it's steps are trivial. Also, it appears that the character is mangled by this forum... it really is a bullet. You should be able to insert these characters in your editor if you are using a decent one.) -mdb |
Author: | fuzzylintman [ Tue Mar 31, 2009 11:17 pm ] |
Post subject: | Re: How to add bullet point |
max1001 wrote: How do I add a bullet point to a paragraph? An example code will be greatly appreciated. I search for forum for example and came up with none.
If you are using MigraDoc, I now see you can also do something like: Code: Paragraph p = sec.AddParagraph();
p.AddCharacter(SymbolName.Bullet); |
Author: | Thomas Hoevel [ Wed Apr 01, 2009 7:39 am ] |
Post subject: | Re: How to add bullet point |
max1001 wrote: How do I add a bullet point to a paragraph? An example code will be greatly appreciated. I search for forum for example and came up with none.
Here's a sample: Code: ListInfo listinfo = new ListInfo();
listinfo.ContinuePreviousList = false;//true for following entries listinfo.ListType = ListType.BulletList1; Paragraph paragraph = Document.LastSection.AddParagraph(text); paragraph.Style = "MyListStyle"; // optional paragraph.Format.ListInfo = listinfo; This way you get a "real bullet list" if you create an RTF file. The method described by fuzzylintman works, too. If you need PDF files, either method can be used. |
Author: | TimJohnston [ Fri Feb 26, 2010 3:57 pm ] |
Post subject: | Re: How to add bullet point |
Thanks for the sample Thomas, but could you elaborate on how to create multiple bullets in the list? I would have assumed you could have re-used ListInfo objects, but it appears you have to create a new one for each paragraph/bullet - is that right? I would have expected some sort of logic like "start list", "add member", "add member", "add member" then "end list". Or use line breaks within a single paragraph to differentiate bulleted items. Could you post code showing how to create a longer bulleted list using a loop? Thanks, TJ |
Author: | Thomas Hoevel [ Mon Mar 01, 2010 9:05 am ] |
Post subject: | Re: How to add bullet point |
TimJohnston wrote: I would have assumed you could have re-used ListInfo objects, but it appears you have to create a new one for each paragraph/bullet - is that right? MigraDoc manages the list - you mark the paragraphs as list members. You use Code: listinfo.ContinuePreviousList = false; for the first entry in a list and Code: listinfo.ContinuePreviousList = true;// for subsequent entries in the same list (makes a big difference for numbered lists). Here are two helper routines I use: Code: bool continueList; protected void DefineList() { continueList = false; } protected void AddToList(TemplateTable tt, string text) { ListInfo listinfo = new ListInfo(); listinfo.ContinuePreviousList = continueList; listinfo.ListType = ListType.BulletList1; Paragraph paragraph = Document.LastSection.AddParagraph(text); paragraph.Style = tt.GetBulletListStyle(Document); paragraph.Format.ListInfo = listinfo; continueList = true; } TemplateTable provides formatting info and is not relevant here. DefineList() only sets a member variable so next time a new list will be created. AddToList() is called for each entry. |
Author: | () => true [ Fri Nov 05, 2010 6:46 am ] |
Post subject: | Re: How to add bullet point |
Here's a sample (a few lines added to the HelloWorld sample): Code: // Add some text to the paragraph paragraph.AddFormattedText("Hello, World!", TextFormat.Italic); // Add Bulletlist begin Style style = document.AddStyle("MyBulletList", "Normal"); style.ParagraphFormat.LeftIndent = "0.5cm"; string[] items = "April|May|Summer|Wednesdays".Split('|'); for (int idx = 0; idx < items.Length; ++idx) { ListInfo listinfo = new ListInfo(); listinfo.ContinuePreviousList = idx > 0; listinfo.ListType = ListType.BulletList1; paragraph = section.AddParagraph(items[idx]); paragraph.Style = "MyBulletList"; paragraph.Format.ListInfo = listinfo; } // Add Bulletlist end return document; I didn't use the AddToList method to have it all in one place. In a real application I'd use that method (it's a user-defined method, code given above in this thread). |
Page 1 of 1 | All times are UTC |
Powered by phpBB® Forum Software © phpBB Group https://www.phpbb.com/ |