PDFsharp & MigraDoc Foundation
https://forum.pdfsharp.net/

Applying formatting to only a portion of output
https://forum.pdfsharp.net/viewtopic.php?f=2&t=53
Page 1 of 1

Author:  bressljr [ Mon Jan 15, 2007 6:32 pm ]
Post subject:  Applying formatting to only a portion of output

Hello. Is there a way to apply formatting to only a select portion of the string that is being fed through the Drawstring method? In other words, if I have the following sentence:

"You hae selected Product X which contains...blah, blah, blah"

If I wanted to put a gray background behind "Product X", is there some way that I can do that without breaking the sentence up into separate strings?

Thanks

Author:  cmgarnett [ Thu May 31, 2007 8:45 am ]
Post subject:  Did you find an answer

Hi

I have to do something similar in that I want to embed one or two emboldened words into a sentence. Did you ever find an answer?

Cheers.

Author:  bressljr [ Thu May 31, 2007 3:17 pm ]
Post subject:  Reply

I never found the answer and ended up switching my solution to use ITextSharp instead. Not saying that there wasn't a solution with PDFSharp, I just was up against a deadline and happened to find out how to do it with Itext, so went that route. Sorry :(

Author:  Thomas Hoevel [ Thu May 31, 2007 3:41 pm ]
Post subject:  Re: Did you find an answer

Hi!
cmgarnett wrote:
I have to do something similar in that I want to embed one or two emboldened words into a sentence. Did you ever find an answer?

I can't tell you how to do it with PDFsharp (but it surely can be done).
We normally use MigraDoc for rich formatted texts.
Code:
        FormattedText ft = paragraph.AddFormattedText("foo", TextFormat.Bold);
        ft.Font.Size = 6;

Some attributes can be set with AddFormattedText directly, all can be set through the FormattedText object you get.

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