So I am writing to a pdf through java using iText. I want to have a blank signature and date spaces underlined. Everything I read said to do it like so:
Chunk sigUnderline = new Chunk(" ");
sigUnderline.setUnderline(0.2f, -2f);
Chunk dateUnderline = new Chunk(" ");
dateUnderline.setUnderline(0.2f, -2f);
verificationList.open();
verificationList.add(new Paragraph("Authorized Signature: " + sigUnderline + "Date: " + dateUnderline));
verificationList.close();
So basically I am trying to underline blank strings to create these "fields". I have also tried to put text in the string(s), and the underlining still doesnt work. Is there something I am missing, any help would be appreciated. Thanks!
解决方案
You are concatenating String with Chunk objects. Add the underlines as Chunk's
Chunk sigUnderline = new Chunk(" ");
sigUnderline.setUnderline(0.1f, -2f);
Chunk dateUnderline = new Chunk(" ");
dateUnderline.setUnderline(0.1f, -2f);
Paragraph para = new Paragraph("Authorized Signature: ");
para.add(sigUnderline);
para.add(new Chunk(" Date: "));
para.add(dateUnderline);
document.add(para);