Free Support Forum - aspose.com

Font determination when generating PDF

Hi,
We’re almost finished evaluating the Aspose.Words product (for Java). It looks fabulous!

There is (for now) one question left:
When generating PDF from doc and docx documents regularly ‘strange’ fonts are not used when generating the PDF.

In our font directory (as it is used by Aspose.Words) numerous fonts are available (basically the combination of MS (Vista) fonts folder (ttf and ttc) and a Mac OSX fonts folder (only the otf fonts))

E.g. We have a document with font “Calibri (Headings)” (as indicated in MS Word as font) and the font folder contains a file named calibri.ttf, calibrib.ttf, calibrii.ttf, calibriz.ttf (normal, bold, italics and bold-ital)

Generating the document renders a PDF where there are only TimesNewRoman variants are present.

1. Can you tell me how to determine if the font is really missing? (Clicking on the font gives a ‘human readable name’; is this the name that is displayed in Word ?)

2. Is there a way to find the fonts in a document and find the fonts available to Aspose.Words for PDF generation ?

Thanks,
Jan

Hi

Thanks for your request.

Could you please attach your document here for testing? Maybe there is something wrong with document, but not with fonts. We will check the issue and provide you more information.

1. If you open the font file, you will see the font name at the top. Please see the attached screenshot. I suppose “human readable name” returns the same value.

2. You can use code like the following to check what fonts are using in a particular document:

// Open document.

Document doc = new Document("C:\\Temp\\in.docx");

// Print all fonts used in the document.

for(int i=0; i<doc.getFontInfos().getCount(); i++)

{

FontInfo info = doc.getFontInfos().get(i);

System.out.println(info.getName());

}

Hope this helps.

Best regards,