Hi ,
We are processing the html file into word using the below code . We will split the pages using page break tag. A pages list will be passed and then we will write each page wise into document using aspose word.
If I am writing all over the html as a page( a string not a list of string) then the bullet font is arial. If i am writing as a page wise then the bullet numbers font is times new roman.
Ex: A html contains 17 pages, If i write full 17 pages data as a string into word then the font is fine . If i write each page wise data then the font is times new roman.
We are facing this font issue in our many clients.
For our reference : This is regarding defect 6789 .
Code we used currently :
string[] values = AsposeExtensions.SplitPageBreak(itemDto.Content);
var listPage = new List(values);
SaveDynamicDocument(listPage, strFilePath, strLeftHeader, strRightHeader);
public static string[] SplitPageBreak(String htmlData)
{
if (htmlData.Contains("<div style=“page-break-after: always;”><span style=“display: none”>
")) return htmlData.Split(new string[] { “<div style=“page-break-after: always;”><span style=“display: none”>
" }, StringSplitOptions.RemoveEmptyEntries); else if (htmlData.Contains(”<div style=“page-break-after: always”><span style=“display: none;”>
“)) return htmlData.Split(new string[] { “<div style=“page-break-after: always”><span style=“display: none;”>
" }, StringSplitOptions.RemoveEmptyEntries); else if (htmlData.Contains(”<div style=“page-break-after: always;”><span style=“display: none;”>
“)) return htmlData.Split(new string[] { “<div style=“page-break-after: always;”><span style=“display: none;”>
" }, StringSplitOptions.RemoveEmptyEntries); else
return htmlData.Split(new string[] { “<div style=“page-break-after: always”><span style=“display: none”>
" }, StringSplitOptions.RemoveEmptyEntries); }
public void SaveDynamicDocument(List listPage, string filePath, string strLeftHeader, string strRightHeader)
{
var doc = new Document();
var builder = new DocumentBuilder(doc);
doc.Sections.Clear();
var newSec = new Aspose.Words.Section(doc);
newSec.ProtectedForForms = true;
newSec.PageSetup.SectionStart = SectionStart.Continuous;
for (int i = 0; i < listPage.Count; i++)
{
var listSection = new List() { listPage[i] };
CreateDocSections(listSection, doc, builder, i);
}
doc.Save(filePath);
}
private void CreateDocSections(List listSection, Document doc, DocumentBuilder builder, int pageIndex)
{
for (var i = 0; i < listSection.Count; i++)
{
var newSec = new Aspose.Words.Section(doc);
if (pageIndex == 0)
newSec.PageSetup.SectionStart = SectionStart.Continuous;
else
{
if (i == 0)
newSec.PageSetup.SectionStart = SectionStart.NewPage;
else
newSec.PageSetup.SectionStart = SectionStart.Continuous;
}
doc.Sections.Add(newSec);
builder.MoveToSection(_countSectionIndex);
FontSettings.DefaultInstance.DefaultFontName = “Arial Unicode MS”;
_countSectionIndex += 1;
if (listSection[i].Contains(”<input name=“hdnLandscape” type=“hidden” value=“MakeLandscape” />”))
{
newSec.PageSetup.Orientation = Orientation.Landscape;
builder.InsertHtml(listSection[i].Replace(”<input name=“hdnLandscape” type=“hidden” value=“MakeLandscape” />”, “”));
}
else
{
newSec.PageSetup.Orientation = Orientation.Portrait;
builder.InsertHtml(listSection[i]);
}
}
}