Aspose.Words for C# Docx to PDF conversion fonts

Dear support,

We bought a license for Aspose.Words after using a temporary license, and so far this product worked well.
The only thing that is not quite clear to us, is why (during conversion in C#) the fonts of the word document are not copied along with the other content of the doc.

The font we’re using in the word document is Myriad Pro, which is (usually) converted to the Arial font.
This doesn’t seem like too big of a problem, but since it’s occurred that the conversion changed the font to Gabriola, which is quite the difference, this became a big issue. Since we are not sure when it converts the font to arial, and when it converts the font to something else, this issue needs to be solved.

Now my question remains: Is there a possibility to embed the fonts at the conversion, so the conversion will take those fonts into account and copy them to the generated PDF file?

We wish to know if there is a way, preferably in C#, to do this.
If you happen to know the cause of this issue, we would like to be informed about that aswell.
Since another conversion tool we have used converts the document with another font then the aspose converter, we believe there might be a difference between the two. This other tool is a simple Sharepoint Doc to PDF converter.

The code we use to do this is as follows:

MemoryStream memStream = new MemoryStream();
SharepointDocumentsRepository.GetDocumentFromSharePoint(filePath, isSecret).CopyTo(memStream);
//Creating doc and saving it to a byte array
Document doc = new Document(memStream);
MemoryStream outputStream = new MemoryStream();
doc.Save(outputStream, SaveFormat.Pdf);
byte[] docBytes = outputStream.ToArray();
//Saving file to sharepoint
SharepointDocumentsRepository.CreatePdfFile(pdfPath, docBytes, isSecret);

I hope to hear from you soon.

Best regards ,

Motiv

@MotivITMasters,

Thanks for your inquiry. Please note that Aspose.Words requires TrueType fonts when rendering documents to fixed-page formats (JPEG, PNG, PDF or XPS). You need to install fonts that are used in your document on the machine where you’re converting documents to Pdf. Please refer to the following article:

How Aspose.Words Uses True Type Fonts

If you want to embed font in output PDF, please set the value of PdfSaveOptions.EmbedFullFonts to true. Please also check detail of PdfSaveOptions.FontEmbeddingMode.

If you still face problem, please share your input Word document here for testing? We will investigate the issue on our side and provide you more information.

1 Like

Hello @tahir.manzoor,

I have tried your suggestion, and it seems like it works.

We did not have the required font installed on the server executing the conversions, which caused it to use wrong fonts.
After we installed the font (true type version), we updated the code and added an options object with the FontEmbeddingMode and EmbedFullFonts set to the correct value.
This seemed to work.

Thanks for the quick support.

  • Motiv

@MotivITMasters,

It is nice to hear from you that your problem has been solved. Please feel free to ask if you have any question about Aspose.Words, we will be happy to help you.