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

Free Support Forum - aspose.com

How can I know useable fonts (Aspose.PDF JAVA)

Hi!
I have to know useable fonts

I add the local font path in FontRepository. but application can’t find the font. (Font Not Found Exception)
So, I want to see the font list in FontRepository.
How can I see it?

Here is my code.

(when tomcat started)
FontRepository.addLocalFontPath("/home/emro/font/");

(when PDF is generated)

stamp.getTextState().setFont(FontRepository.findFont(“gulim”, true)); => throw exception (but font folder has gulim ttc)

I use the aspose.word too.
that library provide the fonts list (that I can see)

FontSourceBase[] sources = FontSettings.getDefaultInstance().getFontsSources();
for(FontSourceBase base : sources){
List fontList = base.getAvailableFonts();
Iterator iter = fontList.iterator();
while(iter.hasNext()){
PhysicalFontInfo font = iter.next();
LOG.info(“fontFamilyName : {}”, font.getFontFamilyName());
LOG.info(“fullFontName : {}”, font.getFullFontName());
LOG.info(“Aspose.Word Font : {}”, font.getFilePath());
}
}

But I don’t know How can I see the font list in Aspose.PDF
I need your help.


I found that FontRepository is not global. is it right?

I print the fontPaths (FontRepository.getLocalFontPaths())
when tomcat started -> found the two paths (one is system font path, the other is custom font path)
when pdf is generated -> found one path (only system font path)

If then, whenever I make PDF, should I set the local font paths?? (FontRepository.addLocalFontPath("/home/emro/font/"))


oh! I solved it. I found the setThreadStaticConfigEnabled option.
T.T as expected, read api doc well.

I want to know how to get font list(include font name, font path …)… plz let me know that code… thanks.

@emrokr

Thank you for contacting support.

We are glad to know that the problem has been resolved in your environment. Moreover, you may extract information about the fonts in a PDF with below code snippet. Since those fonts, either as a subset or complete, exist in the PDF document so the font path may not be extracted with Aspose.PDF for Java API.

Document document = new Document(dataDir + "Test_19.2.pdf");
Font fonts[] = document.getFontUtilities().getAllFonts();
for(Font font : fonts)
{
    System.out.println(font.getFontName());
}

We hope this will be helpful. Please feel free to contact us if you need any further assistance.