Free Support Forum - aspose.com

Need help! PdfToImage Font loss


#1

Dear Aspose team,
When we use PDF to convert pictures, the Chinese font is lost, and the generated pictures display all the Chinese random code. Please tell us how to write code to solve this problem.

source pdf:
1.png (90.5 KB)

image :
2.png (10.3 KB)

Thanks for you !!!


#2

@q8015

Thank you for contacting support.

You are facing this problem because of missing fonts in your environment. This could be fixed by installing the font being used in the PDF document.

Please install the font in default font directory or set a path to the font using the FontRepository.addLocalFontPath() or below function with Aspose.PDF for Java 19.2.

String path = "path/to/my/folder";
List<String> fontPaths = FontRepository.getLocalFontPaths();
fontPaths.add(path);
FontRepository.setLocalFontPaths(fontPaths);

If you are working with Aspose.PDF for .NET API, then use below method:

// connect custom font directory
FolderFontSource fs = new FolderFontSource(@"path\to\my\folder");
FontRepository.Sources.Add(fs);

In case of any further assistance, please share respective data along with narrowed down code snippet.