Hi,
I am using the formattedtextarea in generator and can not get a non- core font to show.
My code is as follows:
Dim style As FormattedTextAreaStyle = New FormattedTextAreaStyle(FontFamily.Helvetica, 14, False)
Dim formattedText As String = "<font face='ATRotisSemiSerif'> Example of a different font"
Dim MyLabel1 As FormattedTextArea = New FormattedTextArea(formattedText, 0,0, 200, 100, style)
MyLabel1.X = 100 'Sets horizontal position
MyLabel1.Y = 100 'Sets vertical position
MyPage.Elements.Add(MyLabel1) 'Places the label on the PDF
Th resulting pdf does not show the required font. Can you tell me what I'm doing wrong and/or let me have a working example?
Thanks in advance
GJH
Different Fonts
Re: Different Fonts
Support · Mar 22, 2011Hello,
Can please tell us what version of DynamicPDF product you are using? This information will help us to look into this further.
Thabks,
ceTe software Support Team
Re: Different Fonts
Forum member · Mar 22, 2011Hi,
We are using:
DynamicPDF Generator v4.0 for .NET Professional Server License
Thanks
GJH
Re: Different Fonts
Support · Mar 22, 2011Hello GJH,
You can add any TrueType or Type1 fonts to the PDF document using our version 4 DynamicPDF Generator for .NET product. You will have to use the TrueTypeFont class to do this. You will need to create TrueTypeFont object using the required font and then create a FontFamily object out of it. You will need to add this FontFamily to the FontFaces of the FormattedTextArea object. This allows you to add the font faces to the text. Below is the sample code for it.
TrueTypeFont verdanaTTF = new TrueTypeFont(@"Verdana.ttf");
FontFamily fontfamilyVerdanaTTF = new FontFamily("font", verdanaTTF);
string str = "<HTML><Body><p><font face=\"font\">Hello World</font></p></Body></HTML>";
FormattedTextArea formattedTextAreaObj = new FormattedTextArea(str, 100, 200, 400, 400,FontFamily.Helvetica,12,true);
formattedTextAreaObj.FontFaces.Add(fontfamilyVerdanaTTF);
Document doc = new Document();
Page page = new Page();
page.Elements.Add(formattedTextAreaObj);
doc.Pages.Add(page);
doc.Draw(@"C:\Mydocument.pdf");
Thanks,
ceTe Software Support Team.
Re: Different Fonts
Forum member · Mar 22, 2011Thanks for that. I will try it as soon as I get a spare moment.
GJH
Re: Different Fonts
Forum member · Mar 23, 2011Any chance of having the example in VB rather in C#?
Thanks
GJH
Re: Different Fonts
Support · Mar 23, 2011Hello GJH,
Please find the respective VB code to add the TTF font to the PDF document using FormattedTextArea.
Dim verdanaTTF As New TrueTypeFont("Verdana.ttf")
Dim fontfamilyVerdanaTTF As New FontFamily("font", verdanaTTF)
Dim str As String = "<HTML><Body><p><font face=""font"">Hello World</font></p></Body></HTML>"
Dim formattedTextAreaObj As New FormattedTextArea(str, 100, 200, 400, 400, FontFamily.Helvetica, _
12, True)
formattedTextAreaObj.FontFaces.Add(fontfamilyVerdanaTTF)
Dim doc As New Document()
Dim page As New Page()
page.Elements.Add(formattedTextAreaObj)
doc.Pages.Add(page)
doc.Draw("C:\Mydocument.pdf")
Thanks,
ceTe Software Support Team.