如何使用itext将交互式复选框添加到现有PDF文档?

时间:2016-04-21 15:34:35

标签: java itext

PdfReader reader = new PdfReader("in.pdf");
PdfStamper stamper = new PdfStamper(reader, "out.pdf");
PdfWriter writer = stamper.getWriter();
Rectangle position = new Rectangle(36, 760, 144, 790);
//
// how?
//
stamper.close();
reader.close();

P.S。 PDF中没有表格

P.P.S。 itext 2.1.7

1 个答案:

答案 0 :(得分:1)

想出来:

RadioCheckField checkbox = new RadioCheckField(writer, rect, "a-name", "Yes");
checkbox.setCheckType(RadioCheckField.TYPE_CHECK);
checkbox.setChecked(true);
checkbox.setBorderWidth(BaseField.BORDER_WIDTH_THICK);
checkbox.setBorderColor(Color.BLACK);
checkbox.setBackgroundColor(Color.WHITE);
stamper.addAnnotation(checkbox.getCheckField(), 1);