How to apply default font when converting csv to pdf

  • os : centos 7.6

  • os default font : NanumGothic

  • jdk : openjdk 8 and aspost cells java jar

  • The font that we target to apply : Google Noto Sans CJK KR

  • code :

com.aspose.cells.TxtLoadOptions loadOptn = 
        new com.aspose.cells.TxtLoadOptions(com.aspose.cells.LoadFormat.CSV);
loadOptn.setEncoding("EUC-KR");
loadOptn.setStandardFont("Noto Sans CJK KR");
loadOptn.setStandardFontSize(10);
Workbook wb = new Workbook("source.csv", loadOptn);
com.aspose.cells.PdfSaveOptions pdfOptn = 
        new com.aspose.cells.PdfSaveOptions(com.aspose.cells.SaveFormat.PDF);
pdfOptn.setDefaultFont("Noto Sans CJK KR");
pdfOptn.setCheckWorkbookDefaultFont(false);
wb.save("target.pdf", pdfOptn);
  • result pdf font : NanumGothic
  1. How to apply default font “Noto Sans CJK KR” when converting csv to pdf?
  2. How to apply default font “Noto Sans CJK KR” when converting xlsx to pdf?
  3. When converting Xlsx document to pdf, the case when convert Server doesn’t support font that used in xlsx then convert server will replace that unsupported font as default.
    At this point how should i do if i want to replace that unsupported font as “Noto Sans CJK KR”?

@SungHa,

Thanks for the code segment and details.

Your code seems to me ok. Please make sure “Noto Sans CJK KR” font is accessed by Aspose.Cells. By default, Aspose.Cells only checks the following font dirs: “/usr/share/fonts” and “/usr/local/share/fonts” in Linux. If the underlying font is not in these two folders, please use FontConfigs.setFontFolder API to set the font folder at the start of your program, see the document for your complete reference:

Moreover, currently, Aspose.Cells only supports .ttf and .ttc font files, so you cannot use any other font types. Please try using our latest version/fix v19.6.x (in case you are not already using it). If you still find the problem, kindly share your source file, font file(s) and the generated PDF file, we will check it soon.