Aspose.Word save as PDF with different fonts from the original one

Hi, we noticed an issue when using Aspose.Words to save a Word Document to PDF, it generate a document with different fonts from the original one. The resulting PDF end up become three pages but the same input document when save as Docx are only two pages.

We found out that the difference is due to text inside the table on the response column is using font 'Myriad Pro` with Bold style, once remove the Bold style, the generate PDF looks consistent with original Docx.

A demo program I am using:
namespace AsposePDFSaveIssue
{
using Aspose.Words;

class Program
{
    static void Main(string[] args)
    {
        var license = new License();
        license.SetLicense("Aspose.Words.lic");
        var inputFilePath = "PdfSaveIssueInput.docx";
        var outputPdfPath = "PdfSaveIssueOutput.pdf";
        var outputDocxPath = "PdfSaveIssueOutput.Docx"; 
        LoadAndSaveTo(inputFilePath, outputDocxPath);
        LoadAndSaveTo(inputFilePath, outputPdfPath);
    }

    private static void LoadAndSaveTo(string inputFilePath, string outputFilePath)
    {
        var doc = new Document(inputFilePath);
        doc.Save(outputFilePath);
    }
}

}

And the attachment includes the input Docx file and one output saves as Docx and another generated as PDF which has the issue.

AsposeSaveToPDFInputAndOutputs.zip (5.7 MB)

On the testing machine the Myriad Pro font has been installed.MyraidProInstalled.png (14.6 KB)

@DougT,

Please ZIP and attach the following font files here for further testing:

  • ‘Myriad Pro’
  • ‘MyriadPro-Regular’
  • ‘Myriad Pro Light’

Do you see any missing fonts warnings on your end?
How to Receive Notification of Missing Fonts and Font Substitution during Rendering

MS Word 2016 opens ‘PdfSaveIssueInput.docx’ in ‘Compatibility Mode’ and displays three pages on our end (see screenshot). What version of MS Word are you using on your end?

Hi Awais,

My apology, I must be confuse with other test case I had which have two pages vs three pages in PDF, please see my new attached InputAndOutputFiles, AsposeSaveToPdfInputAndOutput.zip (5.7 MB). The difference is in the original and the Docs there are content in the third page, but in PDF there is no content in the third page, the last page in PDF is empty.

I am using Word 2016.

There is no missing fonts warning, but see a few other warnings:

Other: Font ‘SimSun’ is not embedded due to exceeding the maximum allowed size of 4,194,304 bytes.
Other: Table column widths may need to be calculated. Rendered column widths could differ.
At Table 1, Cell 1, Row 2, Table 1, Cell 1, Row 2, Table 1, Section 1
Other: Table column widths may need to be calculated. Rendered column widths could differ.
At Table 1, Cell 1, Row 2, Table 1, Section 1
Other: Table column widths may need to be calculated. Rendered column widths could differ.
At Table 1, Cell 1, Row 3, Table 1, Section 1
Other: Table column widths may need to be calculated. Rendered column widths could differ.
At Table 1, Cell 1, Row 4, Table 1, Section 1
Other: Table column widths may need to be calculated. Rendered column widths could differ.
At Table 1, Cell 1, Row 5, Table 1, Section 1
Other: Table column widths may need to be calculated. Rendered column widths could differ.
At Table 1, Cell 1, Row 2, Table 1, Cell 1, Row 6, Table 1, Section 1
Other: Table column widths may need to be calculated. Rendered column widths could differ.
At Table 1, Cell 1, Row 6, Table 1, Section 1
Other: Table column widths may need to be calculated. Rendered column widths could differ.
At Table 1, Cell 1, Row 2, Table 1, Cell 1, Row 7, Table 1, Section 1
Other: Table column widths may need to be calculated. Rendered column widths could differ.
At Table 1, Cell 1, Row 7, Table 1, Section 1
Other: Table column widths may need to be calculated. Rendered column widths could differ.
At Table 1, Cell 1, Row 2, Table 1, Cell 1, Row 8, Table 1, Section 1
Other: Table column widths may need to be calculated. Rendered column widths could differ.
At Table 1, Cell 1, Row 8, Table 1, Section 1
Other: Table column widths may need to be calculated. Rendered column widths could differ.
At Table 1, Cell 1, Row 2, Table 1, Cell 1, Row 9, Table 1, Section 1
Other: Table column widths may need to be calculated. Rendered column widths could differ.
At Table 1, Cell 1, Row 9, Table 1, Section 1
Other: Table column widths may need to be calculated. Rendered column widths could differ.
At Table 1, Cell 1, Row 2, Table 1, Cell 1, Row 10, Table 1, Section 1
Other: Table column widths may need to be calculated. Rendered column widths could differ.
At Table 1, Cell 1, Row 10, Table 1, Section 1
Other: Table column widths may need to be calculated. Rendered column widths could differ.
At Table 1, Cell 1, Row 2, Table 1, Cell 1, Row 11, Table 1, Section 1
Other: Table column widths may need to be calculated. Rendered column widths could differ.
At Table 1, Cell 1, Row 11, Table 1, Section 1
Other: Table column widths may need to be calculated. Rendered column widths could differ.
At Table 1, Cell 1, Row 2, Table 1, Cell 1, Row 1, Table 1, Cell 1, Row 12, Table 1, Section 1
Other: Table column widths may need to be calculated. Rendered column widths could differ.
At Table 1, Cell 1, Row 1, Table 1, Cell 1, Row 12, Table 1, Section 1
Other: Table column widths may need to be calculated. Rendered column widths could differ.
At Table 1, Cell 1, Row 12, Table 1, Section 1
Other: Table column widths may need to be calculated. Rendered column widths could differ.
At Table 1, Cell 1, Row 2, Table 1, Cell 1, Row 1, Table 1, Cell 1, Row 13, Table 1, Section 1
Other: Table column widths may need to be calculated. Rendered column widths could differ.
At Table 1, Cell 1, Row 1, Table 1, Cell 1, Row 13, Table 1, Section 1
Other: Table column widths may need to be calculated. Rendered column widths could differ.
At Table 1, Cell 1, Row 13, Table 1, Section 1
Other: Table column widths may need to be calculated. Rendered column widths could differ.
At Table 1, Cell 1, Row 2, Table 1, Cell 1, Row 1, Table 1, Cell 1, Row 14, Table 1, Section 1
Other: Table column widths may need to be calculated. Rendered column widths could differ.
At Table 1, Cell 1, Row 1, Table 1, Cell 1, Row 14, Table 1, Section 1
Other: Table column widths may need to be calculated. Rendered column widths could differ.
At Table 1, Cell 1, Row 14, Table 1, Section 1
Other: Table column widths may need to be calculated. Rendered column widths could differ.
At Table 1, Cell 1, Row 15, Table 1, Section 1
Other: Table column widths may need to be calculated. Rendered column widths could differ.
At Table 1, Cell 1, Row 16, Table 1, Section 1
Other: Table column widths may need to be calculated. Rendered column widths could differ.
At Table 1, Section 1
Other: Table column widths may need to be calculated. Rendered column widths could differ.
At Table 1, Primary Footer, Section 1
Other: Table column widths may need to be calculated. Rendered column widths could differ.
At Table 1, First Page Footer, Section 1
By using the following code to handle warning:

// For complete examples and data files, please go to https://github.com/aspose-words/Aspose.Words-for-.NET

using System;
using Aspose.Words;

public class HandleDocumentWarnings : IWarningCallback
{
///


/// Our callback only needs to implement the “Warning” method. This method is called whenever there is a
/// Potential issue during document procssing. The callback can be set to listen for warnings generated during document
/// Load and/or document save.
///

public void Warning(WarningInfo info)
{
// We are only interested in fonts being substituted.
if (info.WarningType == WarningType.FontSubstitution)
{
Console.WriteLine("Font substitution: " + info.Description);
}
else
{
Console.WriteLine("Other: " + info.Description);
}
}
}

All the fonts are embedded in the Words document, so I don’t think it need to be installed?

Thanks

@DougT,

I am afraid, we receive three missing font warnings on our end. Please ZIP and attach the following font files here for further testing:

  • ‘Myriad Pro’
  • ‘MyriadPro-Regular’
  • ‘Myriad Pro Light’

Thanks for your cooperation.

Hi, we only install MyriadPro-Light, MyriadPro-Reguar and MyriadPro-Semibold. I think MyriadPro-Regular is MyriadPro?

As the original word document does has embedded font option enabled , I thought that you don’t need font to be installed?

Thanks

@DougT,

Thanks for sharing the font files. We tested the scenario and have managed to reproduce the same problem on our end. For the sake of correction, we have logged this problem in our issue tracking system. The ID of this issue is WORDSNET-17422. We will further look into the details of this problem and will keep you updated on the status of correction. We apologize for your inconvenience.

Hi @awais.hafeez, thanks for your assistant.

What’s the nature of the issue or possible cause you think?

Also it’s may or may not the direct cause of the issue, but it seems to me the embedded fonts from the Docx is not persistent when save to PDF (otherwise you shouldn’t see the missing font warning message), as embedded fonts should enable by default isn’t it?

@DougT,

This issue (WORDSNET-17422) is currently pending for analysis and is in the queue. Once the analysis of the issue is completed, we may then be able to share the root cause of this issue, Rest assured, we will inform you via this thread as soon as this issue is resolved.

We have noted your concern and will keep you posted on further updates.

We apologize for any inconvenience.