3

I'm using OpenHTMLToPDF to get PDF of HTML but I got # character in my pdf instead of actual characters. I'm using DejavuSans font and I passed to code like this:

   try (InputStream is = pdfTtfFile.getInputStream()) {
        pdfRendererBuilder.buildPdfRenderer().getFontResolver().addFont(() -> is, "deja-sans", null, null, false);
    } catch (IOException e) {
        logger.warn("error while loading DejaVuSans_1.ttf font", e);
    }

I also used deja-sans as font family for body tag:

body {
      font-family: 'deja-sans';
     }

I have to get this is in PDF: "Hello World! Fıstıkçı Şahap İlkay Günel"

But I'm getting this in PDF: "Hello World! F#st#kç# #ahap #lkay Günel"

According to sandbox, deja-sans should be fine for me but I don't know what is wrong? Why does it show # instead of my characters?

İlkay Gunel
  • 712
  • 2
  • 11
  • 24
  • I'm sorry but I don't understand clearly. I downloaded ttf file of Dejavu Sans from here: https://www.fontsquirrel.com/fonts/dejavu-sans My style definition is exactly same with definition in the sandbox. https://sandbox.openhtmltopdf.com/ – İlkay Gunel Oct 19 '21 at 11:53
  • were you able to resolve..am in getting ### for Japanese characters – NoOne May 04 '22 at 09:11
  • I found a working solution. This is for whoever comes here for solution : Refer https://stackoverflow.com/questions/55339298/openhtmltopdf-embed-a-custom-font-into-pdf-created-out-of-html. And cjk font is given here : https://github.com/indigofeather/fonts/blob/master/NotoSansCJKtc-Regular.ttf – NoOne May 04 '22 at 13:10

0 Answers0