Free Support Forum - aspose.com

Font changing during Word to PDF conversion

Hello,

We are using Aspose.Words (4.4.1.0) to generate documents and Aspose.PDF (3.6.1.0) for conversion of the generated documents.

We have noticed that text in Gil Sans font gets converted into Times Roman, how do we overcome this problem?

Thanks,

Barsana

Hi,

Can you please provide us with the word document that you are having problems with and the code that you are using for conversion.

Thanks.

Hello,

Please find below the code and a test document.

Any help will be appreciated.

Barsana

Conversion Code is as follows:

using (MemoryStream itemDocumentStream = new MemoryStream())

{

using (MemoryStream itemPDFStream = new MemoryStream())

{

Document itemDocument = AsposeWordsHelper.ConvertBytesToWordDocument(item.GeneratedDocument.Content);

itemDocument.Save(itemDocumentStream, SaveFormat.AsposePdf);

//Create a new pdf converter object

Aspose.Pdf.Pdf pdfConverter = new Aspose.Pdf.Pdf();

// Bind content from the document stream

pdfConverter.BindXML(itemDocumentStream, null);

//This code is needed to ensure performance for documents with bullet points and other formatting

//Fix suggested by aspose.

pdfConverter.IsTruetypeFontMapCached = true;

pdfConverter.TruetypeFontMapPath = _asposeTempPath;

// Save the result to stream

pdfConverter.Save(itemPDFStream);

//Now convert the document to byte[]

byte[] documentToReturn = itemPDFStream.ToArray();

return documentToReturn;

}

}

I can't reproduce this error.

1) Please make sure the font is correctly installed in your system.

2) If you installed the font after the Aspose.Pdf.TruetypeFontMap.xml being generated in _asposeTempPath, please delete that xml file and let it be regenerated.

3) Try the latest version of Aspose.Words and Aspose.Pdf.