简体   繁体   中英

List symbol not showing when inputing a special character in List.setListSymbol() in itext7

I am trying to set the list symbol for my list to ☐ but for some reason when the pdf is created, nothing shows.

I tried

List list = new List().setListSymbol("\u2610");

And also,

List list = new List().setListSymbol("☐");

I also tried

List list = new List().setListSymbol(">");

just to make sure the code was working and it was - the list showed up with ">" as the bullet point.

How can I get the bullet point of my list to be "☐"?

Can you try the following code to render "☐" as bullet point.

    PdfWriter writer = new PdfWriter("src/main/resources/test/list.PDF");
    PdfDocument pdfDoc = new PdfDocument(writer);
    pdfDoc.setDefaultPageSize(PageSize.A4);
    Document doc = new Document(pdfDoc);
    
    PdfFont unicodeFont = PdfFontFactory.createFont("src/main/resources/test/arial.ttf", PdfEncodings.IDENTITY_H);
    
     List list = new List();
     list.setFont(unicodeFont);
     list.setListSymbol("☐");

     list.add(new ListItem("list 1"));
     list.add(new ListItem("list 2"));
     list.add(new ListItem("list 3"));
     
     doc.add(list);
     doc.close();

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM