简体   繁体   English

在 itext7 的 List.setListSymbol() 中输入特殊字符时不显示列表符号

[英]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.我正在尝试将我的列表的列表符号设置为 ☐ 但由于某种原因,在创建 pdf 时,没有任何显示。

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();

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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