This project has moved. For the latest updates, please go here.

Unable to process 'Face' attribute of <Font> tag

Dec 16, 2010 at 10:30 AM

Hi,

I am using  HTMLtoOpenXML.dll v1.3.

it dosent process the "Face" attribute of <FONT> tag

Here is the sample code I am using

<P><FONT face="Verdana" size=4>Sample Text</FONT></P>

Please help!!!!

Coordinator
Dec 19, 2010 at 5:27 PM

You are right, the face attribute is not processed, nor any font-family attributes.

In fact, when the user copy-paste some text into a rich text control, lots of garbage are added (like the font-family). This is the reason why I ignore these attributes.

 

I will maybe consider adding a property to toggle this behavior.

For the moment, if you need to handle it, you should add this piece of code in "ProcessFont" method:

 

attrValue = en.Attributes["face"];
if (attrValue != null)
{
       styleAttributes.Add(new RunFonts { Ascii = attrValue });
}

Jan 31, 2012 at 6:22 AM
Edited Jan 31, 2012 at 6:23 AM

I am using  HTMLtoOpenXML.dll v1.4.2

this is my string coming from database

string Desc =<span style="font-style: italic; font-family: times new roman,times,serif; color: #ff66cc; font-size: 36pt; font-weight: bold">Test2</span>

 text50.Text = Desc;

How to apply Font name and font size

this is my code:

string Desc =<span style="font-style: italic; font-family: times new roman,times,serif; color: #ff66cc; font-size: 36pt; font-weight: bold">Test2</span>

 text50.Text = Desc;


MainDocumentPart mainPart = document.MainDocumentPart;                           

HtmlConverter converter = new HtmlConverter(mainPart);                           

Body body = mainPart.Document.Body;                           

var paragraphs = converter.Parse(text50.Text);                           

for (int h = 0; h < paragraphs.Count; h++)                           

{                               

run50.Append(paragraphs[h]);                   

  }                           

run50.Append(runProperties50);