PDFsharp & MigraDoc Foundation
http://forum.pdfsharp.de/

changing font, size and leading in a paragraph
http://forum.pdfsharp.de/viewtopic.php?f=2&t=2639
Page 1 of 1

Author:  jakewilliamson [ Mon Nov 11, 2013 3:40 pm ]
Post subject:  changing font, size and leading in a paragraph

hi,

i'm trying to achieve something like this using migradoc and then saving to a pdf:

Image

so far i've tried doing it with text, changing the font size of the quotes and the text:

Code:
var quote = sec.AddParagraph();
quote.Format.Alignment = ParagraphAlignment.Left;

var openQuote = quote.AddFormattedText("\"");
openQuote.Font.Name = "Georgia";
openQuote.Font.Size = 50;
openQuote.Font.Color = MigraDoc.DocumentObjectModel.Colors.Blue;

var quoteText = quote.AddFormattedText("Lorem ipsum dolor sit amet, consectetur adipiscing elit. Mauris vel felis et orci molestie tincidunt a vel nisl. Etiam sagittis fermentum nunc a imperdiet. Nunc interdum orci nec ipsum faucibus, non hendrerit purus adipiscing.");
that it has to offer. There is absolutely no surprise that this is the case.");
quoteText.Font.Name = "Georgia";
quoteText.Font.Size = 10;
quoteText.Font.Color = MigraDoc.DocumentObjectModel.Colors.Green;

var closeQuote = quote.AddFormattedText("\"");
closeQuote.Font.Name = "Georgia";
closeQuote.Font.Size = 50;
closeQuote.Font.Color = MigraDoc.DocumentObjectModel.Colors.Blue;


which gave me:

Image

the issue with this one is the leading on the quotes - i can't find how to do the leading?!?!

so i had a think, and tried to the the quotes as images:

Code:
var quote = sec.AddParagraph();
quote.Format.Alignment = ParagraphAlignment.Left;

quote.AddImage(String.Format("{0}media/quote_left.png", PdfTemplatePath));

var quoteText = quote.AddFormattedText("Lorem ipsum dolor sit amet, consectetur adipiscing elit. Mauris vel felis et orci molestie tincidunt a vel nisl. Etiam sagittis fermentum nunc a imperdiet. Nunc interdum orci nec ipsum faucibus, non hendrerit purus adipiscing.");
quoteText.Font.Name = "Georgia";
quoteText.Font.Size = 10;
quoteText.Font.Color = MigraDoc.DocumentObjectModel.Colors.Green;

quote.AddImage(String.Format("{0}media/quote_right.png", PdfTemplatePath));


which gave me:

Image

which is closer - but i don't seem to be able to control the alignment of the closing qote image?!?!

am i heading in the right direction with either of these solutions (and missing the final piece of the puzzle...) or is this kinda thing a bit beyond the scope of migradoc?!

cheers,

jake

Author:  Thomas Hoevel [ Mon Nov 11, 2013 4:09 pm ]
Post subject:  Re: changing font, size and leading in a paragraph

Hi!

With MigraDoc, all items on a line share the same baseline.
IMHO it's correct to use bitmaps.

The bitmaps will be bottom-aligned with the baseline of the characters. Your closing quotes probably have a few empty lines at the bottom.
Playing with "WrapStyle.Through" might lead to the desired result.

See also:
viewtopic.php?p=7198#p7198

Page 1 of 1 All times are UTC
Powered by phpBB® Forum Software © phpBB Group
https://www.phpbb.com/