Free Support Forum - aspose.com

Times New Roman

Context:
A Java web platform that uses the mail merge feature provided by Aspose Word. This Java platform is designed to run on Windows/Linux/MacOs. Users access it through there web browser.

Problem:
As users upload their Word document, Windows users often use the Time New Roman font.
This font is copyrighted by Microsoft and cannot be legally installed on a non Windows platform.
When a user has this font used in a Word document, the new Aspose Word 10 version is triggering a “<!–[if gte mso 9]>
<w:WordDocument>
<w:View>Normal</w:View>
<w:Zoom>0</w:Zoom>
<w:TrackMoves/>
<w:TrackFormatting/>
<w:HyphenationZone>21</w:HyphenationZone>
<w:PunctuationKerning/>
<w:ValidateAgainstSchemas/>
<w:SaveIfXMLInvalid>false</w:SaveIfXMLInvalid>
<w:IgnoreMixedContent>false</w:IgnoreMixedContent>
<w:AlwaysShowPlaceholderText>false</w:AlwaysShowPlaceholderText>
<w:DoNotPromoteQF/>
<w:LidThemeOther>FR</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:DontVertAlignCellWithSp/>
<w:DontBreakConstrainedForcedTables/>
<w:DontVertAlignInTxbx/>
<w:Word11KerningPairs/>
<w:CachedColBalance/>
</w:Compatibility>
<w:BrowserLevel>MicrosoftInternetExplorer4</w:BrowserLevel>
<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]–><!–[if gte mso 10]>

/* Style Definitions */ table.MsoNormalTable {mso-style-name:"Tableau Normal"; mso-tstyle-rowband-size:0; mso-tstyle-colband-size:0; mso-style-noshow:yes; mso-style-priority:99; mso-style-qformat:yes; mso-style-parent:""; mso-padding-alt:0cm 5.4pt 0cm 5.4pt; mso-para-margin:0cm; mso-para-margin-bottom:.0001pt; mso-pagination:widow-orphan; font-size:11.0pt; font-family:"Calibri","sans-serif"; mso-ascii-font-family:Calibri; mso-ascii-theme-font:minor-latin; mso-fareast-font-family:"Times New Roman"; mso-fareast-theme-font:minor-fareast; mso-hansi-font-family:Calibri; mso-hansi-theme-font:minor-latin; mso-bidi-font-family:"Times New Roman"; mso-bidi-theme-font:minor-bidi;}

<![endif]–><span style=“font-size: 8.5pt; font-family: “Verdana”,“sans-serif”; color: red;”>Cannot find any fonts
installed on the system
".

This exception is fatal and the document cannot be merged. If the document is cleaned (use of TNR removed), then the merge is working.
I have read the explanation (need to calculate height of sections of the merged document), and I understand the new design.

But:
You cannot prevent users from using font that may not be installed on merging platforms… And having an exception without any way to override it is not acceptable for a tool which goal is to be ran on any OS…

In some other tools (jasper report for example), there is a feature that force the engine to ignore missing fonts, the document is generated but missing fonts are replaced (instead of having an exception).

Is this something planned for Aspose Word ?
If nothing is planned, is there a way (I have seen doc.getFontInfos() that show used fonts), to detect and replace missing fonts by code ?

Regards.

Hello

Thanks for your request. I think there is no sense to improve this mechanism because this exception is thrown only where there are no fonts at all. If there is at least one fonts Aspose.Words will use it. If Aspose.Words cannot find some of fonts, it uses another similar font. It is alredy done.

I.e. Aspose.Words does not throw where cannot find a specific font.

Best regards,

Hello,

I have attached two documents to this message that show the problem (on a non Windows platform -> Linux version 2.6.18-164.el5 (mockbuild@builder16.centos.org) (gcc version 4.1.2 20080704 (Red Hat 4.1.2-46)) #1 SMP Thu Sep 3 03:33:56 EDT 2009)

The first document (NOTNR.doc) contains Arial text and merge fields.
If you try to merge it and output a PDF, everything is fine.

The second document (TNR.doc) contains Arial text and merge fields AND Times new roman page number in the footer
If you try to merge it and output a PDF, you get the java.lang.IllegalStateException: Cannot find any fonts installed on the system.

This behaviour is not coherent with your previous message.
If I got you well, on the same system, either you always get an exception because fonts are not installed, either missing fonts (Times New Roman here) are replaced.

Can you try on your side and confirm this is a problem with the expected result ?

Best Regards

Hello

Thank you for additional information. I will install Linux and let you know how it goes on my side. Please expect replay within the next few days.

Best regards,

Hi

Thanks for your request. I check the behavior in Linux (Ubuntu 11.04) and all works as expected. Here is code I used for testing:

FontSettings.setFontsFolder("/home/alexey/fonts", true);

Document doc = new Document("/home/alexey/Downloads/TNR.doc");

doc.save("/home/alexey/Downloads/out.pdf");

For testing purposes, I put only one (arial.ttf) font into the fonts directory. Then I tried to convert documents you have attached in your previous post and both documents are converted without any exceptions on my side.

Best regards,

In my code I did not set a font folder and it did not work as expected (as I was explained on the first reply -> As long as you have one font installed on the system the exception should not occur as fonts are replaced)

(1 file works -> font installed / 1 another file does not work with this exception -> why did the first file work ?)

I will try to set a font folder and an authorized font to check if it works.
(apparently Arial is also a proprietary font from microsoft that you cannot install on a linux system)

Regards

Hi

Thank you for additional information. If you do not specify location of the fonts folder, then Aspose.Words does not know where to look for fonts and throws an exception. At the moment Aspose.Words by default looks for fonts in Windows fonts directory, i.e. C:\Windows\Fonts. So when you perform conversion on a non-Windows OS, you have to specify folder with fonts.

Best regards,

That’s what I did, on non windows OS (Linux/Mac OS), I now define default font folders and the merge process is fine.
Thanks for your help.

Regards


Hi

It is perfect that you managed to resolve the problem. Please let us know if you need more assistance, we are always glad to help you.

Best regards,