Quantcast
Channel: Aspose.Pdf Product Family
Viewing all articles
Browse latest Browse all 3131

Embed glyphs into PDF

$
0
0
Hallo

Is it possible to embed only used glymphs into the PDF?
I searched through the documentation, but only found something like RemoveDuplicatedFonts and RemoveSimilarFontsWithDifferentWidths. That is not what I want.
I want to know whether it is possible to tell aspose to embed only the glyphs that are actually used, instead of the whole font.

The problem I have is that the PDF gets very large when using certain fonts. If I use "NotoSansCJKjp-Regular" font from Google Noto Fonts, the document increases in size with more than 10MB.

The code snippet below demonstrates this issue. There is one table and 2 cells with some text. The result is saved in the attachment: "ResultNoto.pdf".
If I comment out the line of code that specifies usage of "NotoSansCJKjp-Regular", the resulting PDF more than 10MB smaller: "Result.pdf".
The files are attached and the sample code is below:

        List<String> fontPaths = com.aspose.pdf.Document.getLocalFontPaths();
        fontPaths.add("C:\\temp\\Noto-hinted");
        com.aspose.pdf.Document.setLocalFontPaths(fontPaths);
        
        List<String> inputStringList = new ArrayList<>();
        inputStringList.add("äöüß é ç Здравствуйте 3 df a dad  a END");
        inputStringList.add("äöüß é ç Здравствуйте  昨夜のコンサートは最高でし adsf dfg END");
        
        com.aspose.pdf.Document doc = new com.aspose.pdf.Document("Blank.pdf");
        com.aspose.pdf.Table table = new com.aspose.pdf.Table();
        table.getDefaultCellTextState().setFont(com.aspose.pdf.FontRepository.findFont("NotoSansCJKjp-Regular"));
        table.setColumnWidths("400");
        
        for (String currentString : inputStringList) {
            Row row = table.getRows().add();
            row.getCells().add(currentString);
        }


I am using aspose.pdf verson 11.8.0
        
Thank you,
Samuel

Viewing all articles
Browse latest Browse all 3131

Trending Articles