P.S. P.S. - 3 months ago 7
Java Question

How add checkobox in Pdf file in itexpdf 7

How can I add a checkobox into a Pdf file like it is done in this question, but using iText 7?

I want the result to look like this:

expected result

Answer

Adapting Bruno's answer to iText 7:

Paragraph p = new Paragraph("This is a tick box character: ");
PdfFont zapfdingbats = PdfFontFactory.createFont(FontConstants.ZAPFDINGBATS);
Text chunk = new Text("4").setFont(zapfdingbats).setFontSize(14);
p.add(chunk);
document.add(p);