Hi,
I’m using DocumentBuilder along with InsertHtml() and Write() to generate .doc file.
I use InsertHtml() when string contains html tags and use Write() when string doesn’t contain html tag.
The default font is Arial. However, the font always became “Cambria” when using InsertHtml().
Is there a way to avoid the problem from happening?
-------------------------------
DocumentBuilder db = new DocumentBuilder(docTemplate);
if (bookmark != null)
{
db.MoveToBookmark(key[i]);
Regex tagRegex = new Regex(@"<.*?>");
string bookmark_value = value[i];
if (tagRegex.IsMatch(bookmark_value))
{
db.InsertHtml(value[i]);
}
else
{
db.Write(value[i]);
}
}
----------------------------------------------
Thank you
- Please supply us with the input document that is causing the issue
- Please supply us with the input HTML
- Please supply us with the output document showing the undesired behavior
Hi,
Thank you for your reply.
Please find the attached documents and the source code below:
“test_template.dot” is the input document. You can find the font type for each bookmark is Arial.
However, after inserting string into those bookmarks by InsertHtml(). The font type became “Cambria”.
On the other hand, for those the strings inserted by Write(), their font types still remained as “Arial”.
Is there a remedy to stop InsertHtml() from using “Cambria”?
Thank you
----------------------------------------------------------------------------------------
Aspose.Words.Document docTemplate = new Aspose.Words.Document(String.Format(@"{0}", file_name));
BookmarkCollection bookmarks = docTemplate.Range.Bookmarks;
DocumentBuilder db = new DocumentBuilder(docTemplate);
foreach (Bookmark bm in bookmarks)
{
if (bm != null)
{
bm.Text = String.Empty;
db.MoveToBookmark(bm.Name);
db.InsertHtml(“Test Aspose.Word 13.6
inserthtml().
”);
db.Write(“Test Aspose.Word 13.6 Write()”);
}
}
docTemplate.Save(@“c:\test.doc”);
InsertHtmlWithBuilderFormatting(builder, "
some text
");Thank you very much. The solution is great and my problem is resolved.