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

Free Support Forum - aspose.com

Retain Font and Gradient Fill Text Effect during Converting DOCX to PDF using C# Code of Aspose.Words for .NET

Hi,
We encountered some font issues on converting docx to pdf using Aspose.Words.

I attached a zip file containing a sample docx template.

We use such template to generate reports with both docx format and pdf format. In the sample docx template, there are two customized Font types: Mute and Grifo S. They are installed on our client machine now, but in our system, conversion from docx to PDF occurs on our server where these two font types are not installed. I’ve embedded these two fonts into the docx and I believe you should see the fonts when opening the document.

When generating word (docx) report based on the sample template, it is fine without changing our current code, but when converting the word report to pdf report using Aspose.Words API, Mute and Grifo S font types are lost in generated PDF. I wonder whether it could be addressed using your API code without installing the font types on our server. (Currently I’m not sure whether it is permitted.)

The second, you could see Gradient fill effect on the title ‘Actuarial Valuation Report on …’ of the sample docx, but when converting it to PDF report, gradient fill effect is lost as well. Please let me know whether it could be addressed by your API code as well. (I attached the generated sample pdf as well, but in it, the font is fine because it is generated on my own client machine where the fonts are installed, so please focus on gradient fill effect issue only.)

The version of Aspose.Words we use is 17.1.0.0.

Thanks.

2019_04enIFRS_Cover_output.docx.pdf (35.5 KB)

2019_04enIFRS_Cover.zip (56.2 KB)

I could attach my sample code on converting docx to pdf:

            var licWord = new Aspose.Words.License();
            licWord.SetLicense("Aspose.Total.lic");

            Aspose.Words.Document document = new Aspose.Words.Document(@"2019_04enIFRS_Cover.docx");

            Aspose.Words.Saving.PdfSaveOptions options = null;

            options = new Aspose.Words.Saving.PdfSaveOptions();
            //options.EmbedFullFonts = true;

            document.Save(@"2019_04enIFRS_Cover_output.docx.pdf", options);

            Console.WriteLine("Pdf converted.");

@Yesheng,

Regarding the “Gradient fill effect”, the problem occurs because you are using a very old (17.1) version of Aspose.Words for NET. We suggest you to please upgrade to the latest (20.4) version of Aspose.Words for NET on your end. Hope, this helps.

Secondly, we do not see any custom fonts embedded inside “2019_04enIFRS_Cover.docx”. Please ZIP and attach the following font files here for further testing:

  • Mute
  • Grifo S

You can simply copy these font files from Windows machine to inside a custom fonts folder in server machine (no installation is required in this case). After that you just need to specify path to fonts folder location.

Please also check the following article:

Hope, this helps.

Hi hafeez,

Thanks for the reply. I’ve downloaded 20.4 trial version of Aspose.Words to verify whether gradient effect issue is fixed in pdf, but unfortunately, it looks still not work. Please see the attached pdf file. (You could see watermark of your aspose.)

2019_04enIFRS_Cover_output.docx.pdf (64.1 KB)

Sample code is not changed as above.

I attached a zip file containing Mute and GrifoS font types. They’re OTF, not TTF. Will it work with your recommended approach?

Thanks.

MuteGrifoS.zip (288.8 KB)

@Yesheng,

Yes, placing these fonts in custom fonts folder will work.

Regarding the “gradient fill effect”, we tested the scenario further and have managed to reproduce the same problem on our end when using the fonts you provided. For the sake of correction, we have logged this problem in our issue tracking system. The ID of this issue is WORDSNET-20339. 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.

The issues you have found earlier (filed as WORDSNET-20339) have been fixed in this Aspose.Words for .NET 20.6 update and this Aspose.Words for Java 20.6 update.