even after reading this forum post, its still quite confusing how to create a bulletted list using migradoc / pdfsharp. I basically want to display a list of items like this:
Here's a sample (a few lines added to the HelloWorld sample):
// 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 = "Dodge|Nissan|Ford|Chevy".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 in this thread).
A little bit more concise than the above answer:
var document = new Document();
var style = document.AddStyle("BulletList", "Normal");
style.ParagraphFormat.LeftIndent = "0.5cm";
style.ParagraphFormat.ListInfo = new ListInfo
{
ContinuePreviousList = true,
ListType = ListType.BulletList1
};
var section = document.AddSection();
section.AddParagraph("Bullet 1", "BulletList");
section.AddParagraph("Bullet 2", "BulletList");
Style is only created once, including listinfo, and can be re-used everywhere.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With