How to add checkbox in PDF file using iText 7?

How to add a control cell to a Pdf file, how is this done in this question, but using iText 7?

I want the result to look like this:

Expected Result

0
java itext7
source share
2 answers

Adapting Bruno's answer on 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); 
+1
source share

You already know how to check the box in an interactive PDF file. Now you want to know how to add a checkmark symbol to a PDF (not an interactive form).

Check out the TickboxCharacter example in the official documentation. This example was written in response to Delete left and right borders in itextshap and you need a box rectangle (a completely different question in which the OP violated the rules and asked a new question in the comments about the correct answer to his original question).

As you can understand from this example, you need a font that knows how to uncheck. ZapfDingbats is a font like this:

 Paragraph p = new Paragraph("This is a tick box character: "); Font zapfdingbats = new Font(Font.FontFamily.ZAPFDINGBATS, 14); Chunk chunk = new Chunk("o", zapfdingbats); p.add(chunk); document.add(p); 

Another example, putting a checkmark in the absolute position, can be found here: How to write zapfdingbatslist in a pdf in a specific place using iTextSharp

+1
source share

All Articles