mercredi 27 juillet 2022

iTextSharp: Add checkbox inside table cell with text

I want to add two checboxes inside an itexsharp cell on a table. But I don't know how to do it. The check box must NOT be editable. They need to be generated from code, based on user data on DB to check the yes option or the no option.

enter image description here

I try this:

String FONT = "C:\\Windows\\Fonts\\wingding.ttf";
string checkBox = "\u00fe";
string uncheckBox = "o";
BaseFont bf = BaseFont.CreateFont(FONT, BaseFont.IDENTITY_H, BaseFont.EMBEDDED);
Font f = new Font(bf, 12);
Paragraph p = new Paragraph("YES" + checkBox + "\n" + "NO" + uncheckBox, f);

cell = new PdfPCell(p);
table.AddCell(cell);

It works good without the YES and NO text, if I only put both textboxes it workd good. The problem is when I write "YES" + checkbox, because it generate an extrange icon. Any solution?




Aucun commentaire:

Enregistrer un commentaire