我需要使用 Java 的 iText 库创建 PDF 文档。我还需要包含一些复选框,这些复选框是 on/off,具体取决于某些类变量的值。我已经找到了一些关于交互式表单的例子,但是我不需要这种复杂程度:只有一些复选框被添加到基本文档中,如下所示:
public class SamplePDF {
public static final String RESULT = "hello.pdf";
public static void main(String[] args)
throws DocumentException, IOException {
new SamplePDF().createPdf(RESULT);
}
public void createPdf(String filename)
throws DocumentException, IOException {
Document document = new Document();
PdfWriter.getInstance(document, new FileOutputStream(filename));
document.open();
document.add(new Paragraph("Document Heading"));
//
// Add Checkboxes here
//
document.close();
}
}
有帮助吗?
1 回答
以下是使用 Windings 字体的方法:
如果要添加任何额外字符,只需引用 Windings 字符集:http://www.alanwood.net/demos/wingdings.html