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

Free Support Forum - aspose.com

Can we embed otf font into pdf?

Hi,

I want to covert html to pdf using Aspose.PDF. I specify “Noto Sans SC” in html and this font is for Chinese and it’s otf not ttf. After coverting, it said that this font has been embeded. But I open this pdf with Adobe Acrobat Reader DC, word can’t be display normally. Can’ t we embed otf font into pdf?

here is my code:

    FileInputStream fileInputStream = new FileInputStream("C:\\Users\\xxx\\Desktop\\Aspose-Total-Java.lic");
    License license = new License();
    license.setLicense(fileInputStream);
    String out = "C:\\Users\\Lucy Hao\\Desktop\\12345.pdf";
    HtmlLoadOptions htmlLoadOptions = new HtmlLoadOptions();
    FontRepository.loadFonts();
    InputStream inputStream = new FileInputStream("C:\\Users\\xxx\\Desktop\\1234.html");
    Document document = new Document(inputStream, htmlLoadOptions);
    document.save(out);
    // check pdf font
    Document pdfDocument = new Document(out);
    for (Page page : pdfDocument.getPages()) {
        page.getResources().getFonts().forEach(font -> {
            System.out.println(font.getFontName() + ":" + font.isEmbedded() + "," + font.isSubset());
        });
    }

this is log result:

NotoSansSC:true,false

this is html and pdf file:
testfont.zip (7.0 MB)

In Adobe Acrobat Reader DC, words cn’t display normally
111.JPG.png (37.5 KB)

@lucy.hq

Can you please share the above font in .zip format with us so that we can test the scenario in our environment and address it accordingly.

font_Noto_Sans_SC.zip (7.0 MB)
thanks for your reply.

@lucy.hq

We were able to replicate the similar issue in our environment while testing the scenario using Aspose.PDF for Java 21.8. Therefore, an issue as PDFJAVA-40808 has been logged in our issue tracking system for the sake of further investigation. We will look into its details and keep you posted with the status of its rectification. Please be patient and spare us some time.

We are sorry for the inconvenience.