- Home
- Forum
- ASP.NET Web Forms (Classic)
- Font Size for Appended HTML
Font Size for Appended HTML
ONLY). The problem I have is that I cannot change the Font Size. As AppendHTML does not return a TextRange, I explictly apply a style to the paragraph. It appears that all of the CharacterFormat properties are applied except FontSize. This is true for BulitIn and well as added styles.
For Instance:
HTMLStyle = CType(doc.AddParagraphStyle("InsertedHTML"), IWParagraphStyle)
HTMLStyle.CharacterFormat.FontName = "Arial"
HTMLStyle.CharacterFormat.FontSize = 8
HTMLStyle.CharacterFormat.TextColor = Color.Blue
paragraph = section.AddParagraph()
paragraph.AppendHTML("Test One
")
paragraph.ApplyStyle(HTMLStyle.Name)
My paragraph results in blue, Arial text, but 12 point.
Any help appreciated.
Thank you for your interest in Syncfusion products.
We were able to reproduce the mentioned issue.We suspect this could be a defect.We have forwarded this issue to our development team for further analysis.
Could you please report this issue through Direct Trac Developer Support System https://www.syncfusion.com/account/login?ReturnUrl=%2fsupport%2fdirecttrac%2fincidents because you can take the advantage of the expertise of a dedicated support engineer and a guaranteed response time and we hope you will take advantage of this system as well. If you have already reported through Direct trac, please ignore this.
Please let me know if you have any queries.
Regards,
Poornima
bk.MoveToBookmark("xmlcontent"); //or whatever your bookmark is named
bk.DeleteBookmarkContent(false);
var document = new WordDocument();
document.XHTMLValidateOption = XHTMLValidationType.Transitional;
var section = document.AddSection() as WSection;
var paragraph = section.AddParagraph();
paragraph.ParagraphFormat.LineSpacing = 8; //set linespacing in the paragraph
section.Body.InsertXHTML("<body style=\"font-size: 8pt; font-family: Arial\">" + model.XmlContent + "</body>"); //wrapping your xmlcontent inside the <Body> tags and specifying font-size or other properties in the style attribute.
while (section.Body.ChildEntities.Count > 0)
{
textBodyPart.BodyItems.Add(section.Body.ChildEntities[0]); //moving content from the paragraphs in the section into the textBodyPart object
}
bk.InsertTextBodyPart(textBodyPart); //finally inserting the textBodyPart into the bookmark
Hi Halvor,
Thank you for your interest in Syncfusion Products.
In AppendHTML(HTML to Doc) method, DocIO converts HTML DOM (document object
model) to DocIO DOM and then appends the converted object model to the source paragraph.
During this phase, if font information is not specified in the input html
string, default value is taken for the converted object model (paragraphs and
tables). To resolve this issue, kindly apply the paragraph style before calling
AppendHTML() or once after appending HTML we need to manually parse the
appended DocIO object model and specify font information directly. Please refer
the below code snippet for illustrating the same.
Code snippet:
paragraph =
section.AddParagraph()
paragraph.ApplyStyle(HTMLStyle.Name)
paragraph.AppendHTML('<strong>Test</strong>
One<br/>')
Please let us know if you have any other questions.
Regards,
Sivasubramanian
Hi Halvor,
Thank you for your interest in Syncfusion products.
The work around suggested by you with the HTML content contains font size defined inside the body style - font size attribute ("<body style=\"font-size: 8pt; font-family: Arial\">" + model.XmlContent + "</body>"") will work well in both InsertHTML and AppendHTML methods.
On an additional note, Both AppendHTML/InsertHTML (HTML to Doc) method, DocIO converts HTML DOM (document object model) to DocIO DOM and then appends/inserts the converted object model to the source paragraph. During this phase, if font information is not specified in the input html string, default value is taken for the converted object model (paragraphs and tables) causing the reported problem. Hence defining the font size inline in the input HTML string will result in expected output.
For more information, refer below UG documentation.
http://help.syncfusion.com/ug/asp.net/docio/default.htm#!documents/importingxhtml.htm
Please let us know if you have any questions.
Regards
Rajendran
- 4 Replies
- 5 Participants
-
RB Richard Brown
- Jan 1, 2010 04:52 PM UTC
- Apr 10, 2013 07:33 AM UTC