Search code examples
javaitextitext7google-material-icons

Itext 7 using material ui icons in pdf


How do I use material ui icons as font while creating a PDF document. I am trying to use MaterialIcons-Regular.ttf as the font.

Is there any example I can refer to. or is there a better way of handling font icons in PDF docs using itext7.


Solution

  • I'm not completely sure what you're asking but it should go like this:

    PdfFont f1 = PdfFontFactory.createFont("MaterialIcons-Regular.ttf", "Identity-H", true);
    Paragraph p1 = new Paragraph("Testing of symbols \ue000,\ue0bb").setFont(f1);
    

    Note that the characters are in the private area. Install the font in windows and use the character map application to locate the charactres.