Hi,
We are trying convert a word document(docx) to PDF document using Aspose Word library in .NET. We are able to generate PDF document using the code, but it is generating with incorrect font in PDF document.
The word document is using the font ‘MINI Serif’ but the output PDF is generated with some random fonts. '‘MINI Serif’ font is already available in the machinefrom where we generated this PDF.
Could you help me to resolve this issue?
@vineeshm Most likely the problem occurs because the fonts used in your input document are not available on the machine where document is converted to PDF. If Aspose.Words cannot find the font used in the document, the font is substituted. This might lead into fonts mismatch and document layout differences due to the different fonts metrics. You can implement IWarningCallback to get notifications when font substitution is performed.
Please see our documentation to learn where Aspose.Words looks for fonts:
https://docs.aspose.com/words/net/specifying-truetype-fonts-location/
1 Like
@alexey.noskov Thanks for the reply.
As I mentioned in the question, the fonts which are used in input document is already installed in the machine. I will install it again and try.
@vineeshm Could you please attach your input, output document and MINI Serif
font here for testing? We will check the issue and provide you more information.
@alexey.noskov Please find the attached docx file and the pdf file. The fonts in docx and pdf file are different.
Also please note we have applied a valid product license in the server but the pdf file is still showing trial version banner.
below is the code we used for converting to PDF.
var doc = new Document(SourcePath + DocxfileName);
Aspose.Words.Saving.PdfSaveOptions options = new Aspose.Words.Saving.PdfSaveOptions();
options.EmbedFullFonts = true;
options.FontEmbeddingMode = Aspose.Words.Saving.PdfFontEmbeddingMode.EmbedNonstandard;
doc.Save(destinationPath + PDFfilename,options);
MIN.pdf (1.5 MB)
MIN.docx (41.5 KB)
@vineeshm As I have mentioned MINI Serif
font should be available in the environment where the document is converted to PDF, otherwise the fonts is substituted.
Regarding an evaluation message. Please check the following points:
- Make sure your call to
SetLicense
gets executed. Step through in the debugger.
- Make sure your code does not catch an exception thrown by Aspose.Words licensing code. For example, Aspose.Words will throw if it cannot find the license.
- Make sure the input documents do not already have the evaluation message. Aspose.Words does not delete existing evaluation messages.
- Make sure
SetLicense
is executed before you instantiate any Document
object.
@alexey.noskov Thanks for the quick reply.
As I mentioned in the initial post the font MINI serif is already installed in the machine from which we are converitn the file to PDF. But MS Word is not installed on that machine. I am attaching a screenshot of font popup from Notepad from the same machine for your reference.
Regarding the license issue, we will check the steps you have mentioned.
UAT font SS.JPG (80.4 KB)
@vineeshm Could you please attach MINI Serif
font here for testing? We will check the issue and provide you more information.
@alexey.noskov Please find the attached font files for MINI.
MINI.zip (161.0 KB)
@vineeshm As I can see MINISerif
fonts are properly used upon rendering the document. I have used the following code for testing:
Document doc = new Document(@"C:\Temp\in.docx");
doc.WarningCallback = new WarningCallback();
doc.FontSettings = new FontSettings();
doc.FontSettings.SetFontsSources(new FontSourceBase[] { new SystemFontSource(), new FolderFontSource(@"C:\Temp\fonts", true) });
doc.Save(@"C:\Temp\out.pdf");
private class WarningCallback : IWarningCallback
{
public void Warning(WarningInfo info)
{
if (info.WarningType == WarningType.FontSubstitution)
Console.WriteLine(info.Description);
}
}
@"C:\Temp\fonts"
folder contains the fonts you have attached. The code shows the following warnings:
Font 'MINIType v2 Regular' has not been found. Using 'Arial' font instead. Reason: alternative name from document.
Font 'MINI Type Global Pro Regular' has not been found. Using 'Times New Roman' font instead. Reason: alternative name from document.
Font 'MINITypeRegular' has not been found. Using 'Calibri' font instead. Reason: alternative name from document.
MINIType
fonts however are substituted since they are not available.
Substitutions are performed according to the alternative font name specified in the document:
...
<w:font w:name="MINIType v2 Regular">
<w:altName w:val="Arial"/>
<w:charset w:val="00"/>
<w:family w:val="swiss"/>
<w:pitch w:val="variable"/>
<w:sig w:usb0="A00022AF" w:usb1="9000004A" w:usb2="00000008" w:usb3="00000000" w:csb0="0000009F" w:csb1="00000000"/>
</w:font>
...
<w:font w:name="MINI Type Global Pro Regular">
<w:altName w:val="Times New Roman"/>
<w:charset w:val="00"/>
<w:family w:val="auto"/>
<w:pitch w:val="variable"/>
<w:sig w:usb0="00000001" w:usb1="B9DFFFFF" w:usb2="0008001E" w:usb3="00000000" w:csb0="0000009F" w:csb1="00000000"/>
</w:font>
...
<w:font w:name="MINITypeRegular">
<w:altName w:val="Calibri"/>
<w:charset w:val="00"/>
<w:family w:val="swiss"/>
<w:pitch w:val="variable"/>
<w:sig w:usb0="80000027" w:usb1="00000000" w:usb2="00000000" w:usb3="00000000" w:csb0="00000093" w:csb1="00000000"/>
</w:font>
Here is the output PDF produced on my side: out.pdf (91.6 KB)
1 Like
@alexey.noskov Thanks for the solution. We have checked it and it worked for most of the clients. But it didn’t work for one of the client. The only difference we could notice is that the font type of this particular client is ‘ttf’ whereas the font type of the other clients which is working is ‘otf’.
I am attaching a sample document and its font files. Could you check it from your end whether it is converting correctly?
BMW Cars Font.zip (650.2 KB)
BW.docx (70.2 KB)
@vineeshm
We have opened the following new ticket(s) in our internal issue tracking system and will deliver their fixes according to the terms mentioned in Free Support Policies.
Issue ID(s): WORDSNET-25754
You can obtain Paid Support Services if you need support on a priority basis, along with the direct access to our Paid Support management team.
@alexey.noskov Could you please let me know from where I can see the progress of the new ticket opened for this issue?
@vineeshm You could see the status of the logged issues in this topic. Also you will be notified here when the issue fix will be released.
The issues you have found earlier (filed as WORDSNET-25754) have been fixed in this Aspose.Words for .NET 23.9 update also available on NuGet.