Arial font is always added to doc when using HtmlArea

Arial font is always added to doc when using HtmlArea

Forum member · Aug 6, 2021
Whenever I add a an HtmlArea element to a Document, the resulting PDF file ALWAYS has 3 Arial Embedded Subset fonts added even if I have not referenced Arial in anyway in the the HtmlArea string/fragment. I have confirmed that Arial is not referenced in any css, attributes, or other text being added to the document. I have a test document I was able to reliably produce this with. When I comment out the section that adds an HTML blurb, the resulting PDF does not having the Arial embedded fonts. If put the code back into place the html blurb, the PDF ends up with unneeded embedded fonts. (If there was a way to upload these 2 test (before/after) PDFs, I would do that...) Code to add html is pretty simplistic: HtmlArea htmlArea = new HtmlArea(html, 0, CurrY, AvailW, AvailH); [Page object variable].Elements.Add(htmlArea); I am using DynamicPDF.CoreSuite.NET 11.14.0

Re: Arial font is always added to doc when using HtmlArea

Support · Aug 6, 2021
Hello, The behavior you posted above is expected as DynamicPDF Core Suite adds text with a default Arial font, if no font is specified for the text in the HTML source. If you would like to avoid embedding the Arial font then you may want to specify another font in the HTML source. Also please make sure to have that font installed on the system, where in the application is running. Here is a code sample to add text using a specific font and commented code for adding text using a default font. Document document = new Document(); //The below text will be added using specified Calibri font string variableText = "<div style=\"color: black; font-family: 'Calibri';\"><font face=\"calibri\">This to test</font></div>"; //Below text will be added using default Arial font. //string variableText = "<div style=\"color: black; >This to test</font></div>"; HtmlArea textArea = new HtmlArea(variableText, 0, 0, 500, 650); Page page = new Page(); page.Elements.Add(textArea); document.Pages.Add(page); String output = "C:/Temp/HtmlArea.pdf"; document.Draw(output); Thanks, ceTe Software Support Team

Re: Arial font is always added to doc when using HtmlArea

Forum member · Aug 6, 2021
So, the string variable containing the html I am using in the HtmlArea includes: <style> #letterContainer { font-family: Helvetica, sans-serif; font-size: 10pt; } </style> (where the #letterContainer selector is the id of the <div> tag that wraps the rest of the html string) This did not change the results. That is, the PDF file still was created with the embedded Arial font. Is the <style> tag not supported?

Re: Arial font is always added to doc when using HtmlArea

Forum member · Aug 6, 2021
It seems like "Helvetica" is the issue. If I change my <style> tag to specify something like 'Segoe UI', the PDF is generated and, as one might expect, the Segui UI font is embedded. If I change that same <style> tag to just 'Helvetica', the PDF that is generated contains the Arial font embedded.

Re: Arial font is always added to doc when using HtmlArea

Support · Aug 9, 2021
Hi, You are seeing this behavior because Helvetica is not installed on the system. If our API does not find the specified font on the system, it will embed the default Arial font. Thanks, ceTe Software Support Team

Re: Arial font is always added to doc when using HtmlArea

Forum member · Aug 16, 2021
Is this something that can be addressed, perhaps as boolean property (something akin to .EmbedCoreFont = false)? Two things I would add to this conversation: 1) this does not occur if I create a document and place a FormattedTextArea with Helvetica specified. For example, if add a text area like so: FormattedTextAreaStyle(FontFamily.Helvetica, 10, false); then, in the resulting PDF, Arial is NOT embedded. It just embeds Arial when I add the HtmlArea. 2) Helvetica is one of the "core fonts".... why embed it?

Re: Arial font is always added to doc when using HtmlArea

Forum member · Aug 16, 2021
Another testing note: Arial also gets embedded even if the html that is being placed with the HtmlArea object contains a style tag only specifies "sans-serif" <style> #divContainer { font-family: sans-serif; } </style>

Re: Arial font is always added to doc when using HtmlArea

Support · Aug 17, 2021
Hello, 1. There is no option to specify font for HtmlArea object. You will need to handle it in the HTML source. HtmlArea looks for fonts in the systems font folder(C:\Windows\Fonts). If the specified font is not found on the system, then it will add text with default Arial font. This is the reason the Arial font is getting added when you specify Helvetica (in absence of Helvetica). 2. As mentioned above, HtmlArea does not support specifying core fonts, everything must be handled in the HTML source. Regarding another testing note: Please send over following information to [^a|mailto:support@dynamicpdf.com|opennewwindow|support@dynamicpdf.com^] so we can look into further. 1. Code sample which uses static data to recreate behavior. 2. HTML file or text to recreate the behavior 3. Exact version and build number of the DynamicPDF DLL file used in your application. You can find this information by right clicking on the DLL file>>Properties>>Details tab>>Product version. Take a screenshot of Details tab and send it over to us. 4. output PDFs for respective scenarios. 5. More details on the issues by referring to the output PDFs. Thanks, ceTe Software Support Team

Re: Arial font is always added to doc when using HtmlArea

Forum member · Aug 18, 2021
I have emailed the code and resulting PDFs for an extremely test page that demonstrates how adding an HtmlArea element to a page causes Arial to be embedded (in comparison to just adding a TextArea element which does NOT cause Arial to be embedded). In my packages.config file, <package id="ceTe.DynamicPDF.CoreSuite.NET" version="11.14.0" targetFramework="net48" /> From the Properties->Details tab of the DLL: Product version 11.14.0.44107

Re: Arial font is always added to doc when using HtmlArea

Support · Aug 19, 2021
Hi, TextArea and HtmlArea behave differently with the fonts. By default HtmlArea subset embeds the fonts used in the HTML/CSS. It defaults to Arial when the font used in HTML/CSS is not available to add. HtmlArea will not use the PDF core fonts. Thanks, ceTe Software Support Team

Re: Arial font is always added to doc when using HtmlArea

Forum member · Aug 19, 2021
I think there's a request or two in here... - Why default to "Arial" which will, in turn and by default, cause a font to be embedded? Why can't the default be a "core" font (ie, Helvetica)? I'm not sure I understand the the "why" behind the statement "HtmlArea will not use the PDF core fonts." If all PDF readers support Helvetica, why default to a non native font that requires embedding? - So, to get around this default, I add some css to the html string to be added that includes a font reference to Helvetica. This still results in Arial being embedded because, as you mentioned, the requested font (Helvetica, which again, is considered a PDF core font) is not on the machine generating the document. Yet... when a TextArea element instantiated using Helvetica and placed on a page, it "just works." That is Helvetica still does NOT exist on the machine and yet also does NOT result in Arial being embedded (which is, of course, good!) I'm sure you have more deep technical knowledge about how the PDF construction is really working at a low level, but these things seem to be ... inconsistent... from a higher level, as one trying to use the API.

Re: Arial font is always added to doc when using HtmlArea

Support · Aug 23, 2021
Hello, The main reason HtmlArea does not support the Core PDF fonts, is that it has full Unicode support including character shaping. The built core built in PDF fonts only support Latin character sets. Supporting this would potentially cause a font specified in the HTML/CSS to be split, so Latin characters were represented by the core font (Helvetica) and non Latin characters represented by Arial. There would also be a performance cost with doing this. Thanks, ceTe Software Support Team