We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Fallback fonts

We have recently updated the wysiwyg editor in our application. One difference this has made is that it creates markup with fallbacks included for font family attributes.

However when creating a new document in Aspose.Words using InsertHtml() the font declarations are ignored in the output, instead reverting to Times New Roman.

This markup works:

Hello World


This markup does not:

Hello World


For reference, we are using Aspose.Words 4.4.0.0.

Any ideas why this is the case?

On further investigation this markup also does not work:


Hello World


So I’m not entirely sure it is specifically related to fallback fonts.

Hi Brett,

Thanks for your inquiry. I have tested the scenario using latest version of Aspose.Words for .NET 14.10.0 and have not found the shared issue. Please use Aspose.Words for .NET 14.10.0. I have used the following code example to test your scenario. Please check the attached output document.

<!–[if gte mso 9]>
<w:WordDocument>
<w:View>Normal</w:View>
<w:Zoom>0</w:Zoom>
<w:TrackMoves/>
<w:TrackFormatting/>
<w:PunctuationKerning/>
<w:ValidateAgainstSchemas/>
<w:SaveIfXMLInvalid>false</w:SaveIfXMLInvalid>
<w:IgnoreMixedContent>false</w:IgnoreMixedContent>
<w:AlwaysShowPlaceholderText>false</w:AlwaysShowPlaceholderText>
<w:DoNotPromoteQF/>
<w:LidThemeOther>EN-US</w:LidThemeOther>
<w:LidThemeAsian>X-NONE</w:LidThemeAsian>
<w:LidThemeComplexScript>X-NONE</w:LidThemeComplexScript>
<w:Compatibility>
<w:BreakWrappedTables/>
<w:SnapToGridInCell/>
<w:WrapTextWithPunct/>
<w:UseAsianBreakRules/>
<w:DontGrowAutofit/>
<w:SplitPgBreakAndParaMark/>
<w:EnableOpenTypeKerning/>
<w:DontFlipMirrorIndents/>
<w:OverrideTableStyleHps/>
</w:Compatibility>
<w:DoNotOptimizeForBrowser/>
<m:mathPr>
<m:mathFont m:val=“Cambria Math”/>
<m:brkBin m:val=“before”/>
<m:brkBinSub m:val="–"/>
<m:smallFrac m:val=“off”/>
<m:dispDef/>
<m:lMargin m:val=“0”/>
<m:rMargin m:val=“0”/>
<m:defJc m:val=“centerGroup”/>
<m:wrapIndent m:val=“1440”/>
<m:intLim m:val=“subSup”/>
<m:naryLim m:val=“undOvr”/>
</m:mathPr></w:WordDocument>
<![endif]–>

Document doc = new Document();

DocumentBuilder builder = new DocumentBuilder(doc);

builder.InsertHtml(@"

Hello World

Hello World

");

doc.Save(MyDir + "Out.docx");


<!–[if gte mso 10]>

/* Style Definitions */ table.MsoNormalTable {mso-style-name:"Table Normal"; mso-tstyle-rowband-size:0; mso-tstyle-colband-size:0; mso-style-noshow:yes; mso-style-priority:99; mso-style-parent:""; mso-padding-alt:0in 5.4pt 0in 5.4pt; mso-para-margin:0in; mso-para-margin-bottom:.0001pt; mso-pagination:widow-orphan; font-size:10.0pt; font-family:"Times New Roman",serif;}

<![endif]–>Moreover, in version Aspose.Words (14.6.0), we introduced a
new overload method of DocumentBuilder.InsertHtml which allows you to
choose what formatting will be used as a base for inserted HTML
fragments.


The new
overload has an argument useBuilderFormatting which when is false,
formatting specified in DocumentBuilder is ignored, and formatting of
inserted text is based on default HTML formatting. In this case,
inserted text looks as in browsers.

When
useBuilderFormatting is true, formatting of inserted text is based on
formatting specified in DocumentBuilder. Note that useBuilderFormatting
chooses only base formatting of inserted text, and do not affect
formatting directly specified in the HTML fragment.

The following example illustrates the difference between the two modes:

DocumentBuilder builder = new DocumentBuilder();

builder.ParagraphFormat.LeftIndent = 72;

builder.Font.Name = “Arial”;

builder.Font.Size = 24;

bool useBuilderFormatting = …

builder.InsertHtml(

Text

, useBuilderFormatting);

In
this example, if useBuilderFormatting is false, the inserted paragraph
will have no left indent and will use the ‘Times New Roman’ 12pt font,
which is the default HTML font and indent. If useBuilderFormatting is
true, the inserted paragraph will be indented by 1 inch (72 points) and
will use the ‘Arial’ 24pt font, as specified in DocumentBuilder.
However, in both cases the inserted text will be bold and red, as
specified in the HTML fragment.

Thank you for the response Tahir.


Updating Aspose is a risky venture for us considering we are using method overloads in Classic ASP and we have no real means to test if they still work in newer versions. The fact that the version we are using is so out of date amplifies this concern.

Before we consider this upgrade path, can you confirm that this is an issue in 4.4.0.0, and that there are no workarounds?

Hi Brett,

Thanks for your inquiry. This was an issue in older version of Aspose.Words and have fixed in latest versions. Unfortunately, there is no workaround available for this issue.

We
don’t provide support for older released versions of Aspose.Words.
Please note that we do not provide any fixes or patches for old versions
of Aspose products either. All fixes and new features are always added
into new versions of our products. So, you will have to upgrade if you
need new features or fixes. Please download latest version of Aspose.Words from here:
http://www.aspose.com/community/files/51/.net-components/aspose.words-for-.net/entry585147.aspx

Thank you for your clarification and help.