Free Support Forum - aspose.com

How do I make text bold for non-TrueTypeFonts?

I'm using Courier New, 12pt and need to make the text bold. Using TrueTypeFontBold = true does not seem to have any affect.

Here is a code fragment:

loPDFText_ = New Text

loPDFSegment_ = loPDFText_.Segments.Add(lsAddress_)

With loPDFSegment_

.TextInfo.Alignment = AlignmentType.Left

.TextInfo.FontName = "Courier" '"Courier New" 'PR# 05-32: Font Changed to Courier

.TextInfo.FontSize = 12 '10 'PR# 05-32: FontSize changed to 12

.TextInfo.IsTrueTypeFontBold = True

End With

loPDFSection_.Paragraphs.Add(loPDFText_)

Thanks,

Jim K.

Dear Jim,

Thank you for considering Aspose.

Courier is PDF core font. If you want to use Courier bold font, set the font name to be Courier-Bold. Courier New is TrueType font. If you want to use Courier New Bold font, set the IsTrueTypeFontBold to true and make sure the ttf file for Courier New Bold is in your system's fonts directory.

I have tested the following code in my machine and it works well:

Dim p1 As Pdf = New Pdf
Dim loPDFSection_ As Section = p1.Sections.Add

Dim loPDFText_ As Text = New Text

Dim loPDFSegment_ As Segment = loPDFText_.Segments.Add("hello")

With loPDFSegment_

.TextInfo.Alignment = AlignmentType.Left

.TextInfo.FontName = "Courier New"

.TextInfo.FontSize = 12

.TextInfo.IsTrueTypeFontBold = True

End With

loPDFSection_.Paragraphs.Add(loPDFText_)

p1.Save("d:/test/test.pdf")

Thanks, that did the trick. I had to stay with the Courier font, but setting it to Courier-Bold did the trick. Thanks again.

Jim K.