HtmlArea font

Skip Navigation LinksHome  /  Support  /  Forums  /  DynamicPDF CoreSuite for .NET (v10)  /  HtmlArea font

DynamicPDF CoreSuite for .NET (v10) Forum

 Jun 14 2019 3:23 AM
Hi team,

I added HtlmArea to pdf Page, but can you advise me how can I add custom font for HtmlArea. Below is html content:

<ul>
   <li><font face="Angle"><span style="font-size: 22px;">Item1</span></font></li>
   <li><font face="Angle"><span style="font-size: 22px;">Item2</span></font></li>
   <li><font face="Angle"><span style="font-size: 22px;">Item3</span></font></li>
</ul>

Thanks & Regards
 Jun 14 2019 9:34 AM
Posted by a ceTe Software moderator
Hello,
 
You can use CSS styles to set the font for the unordered list. Below is the syntax. The specified font must be installed on the system.
 
<!DOCTYPE html>
<html>
<head>
<style>
.customFont {
font:20px "Verdana";
}
</style>
</head>
<body>
<ul class="customFont">
   <li><span>Item1</span></li>
   <li><span>Item2</span></li>
   <li><span>Item3</span></li>
</ul>
</body>
</html>
 
Thanks,
ceTe Software Support Team
 Jun 18 2019 10:57 PM
Thanks for your supporting,

One more question, could we load fonts for FormattedTextArea using FontFamily then share for HtmlArea?

Thanks & Regards
 Jun 19 2019 9:24 AM
Posted by a ceTe Software moderator
Hello,

The DynamicPDF Generator for .NET product does not support setting FontFamily object to HtmlArea, similar to FormattedTextArea. You will need to use CSS styles to set the required font to the HtmlArea.

Thanks,
ceTe Software Support Team
 Jun 20 2019 1:11 AM
Hi,

I tried to install the fonts to the system then use it in css, but some fonts work and others is not.  Could you adivse me how can I solve it

Thanks
 Jun 20 2019 7:57 AM
Posted by a ceTe Software moderator
Hello,
 
Can you please send over the following details to support@dynamicpdf.com so we can look into it further?
 
1.        HTML file.
2.        Font files.
3.        Code sample which uses static data to recreate the behavior.
4.        Output PDF file.
5.        More details on issue you are facing on your end.
 
Also please include the forum link in your email.
 
Thanks,
ceTe Software Support Team
 Sep 16 2021 11:53 AM
Hi,

I have the same issue . I installed Karantina and Great Vibes fonts to the system and I'm trying to use them in HtmlArea.

I suppose the only difference with the case is I’m using the this HtmlArea constructor: HtmlArea(string text, float x, float y, float width, float height); instead of the one with the argument Uri.

This is my text argument:

string input = @”
<head>
            <style>
            .customFont {
            font:20px ""Karantina"";
            }
            </style>
            </head>

        <p align = ""justify"" style = ""font-size:10px"" class =""customFont"" ><font face = ""Great Vibes"" style = ""font-size:30px"" > You can change the text-align </font > by clicking on one of the properties on the left...</ p >”

Code sample:

      HtmlArea fta = new HtmlArea(input, 50, 50, 250, 250);


In the output pdf, there are no Karantina or Great Vibes fonts.

 Sep 20 2021 2:57 PM
Posted by a ceTe Software moderator
Hello,

We tested this and are unable to recreate the behavior.  Please make sure the specified fonts are installed on the system where in the application is running.

HtmlArea looks for the fonts in the C:\Windows\Fonts folder. If the specified fonts are not installed on the machine, then it will use Arial as the default font.

Also, you can place the fonts in a folder and set that folder path as resource for fonts. This will tell HtmlArea to look fonts in this folder.

Here is a code sample.

          GlobalSettings.PathToFontsResourceDirectory = @"C:\Temp\Resource";
            string input = "<head>" +
           "<style>" +
           ".customFont {" +
           "font: 20px Karantina;" +
           "}" +
           "</style>" +
           "</head>" +
           "<p align=\"justify\" style=\"font-size:10px\" class=\"customFont\">" +
           "<font face=\"Great Vibes\" style=\"font-size:30px\">You can change the text-align</font> by clicking on one of the properties on the left...</p>";

            Document document = new Document();
            HtmlArea htmlArea = new HtmlArea(input, 0, 0, 500, 650);
            Page page = new Page();
            page.Elements.Add(htmlArea);
            document.Pages.Add(page);
            string output = @"C:\Temp\MyDocument.pdf";
            document.Draw(output);

Thanks,
ceTe Software Support Team

All times are US Eastern Standard time. The time now is 6:42 AM.