小编jbo*_*en7的帖子

回复:pdfbox库; 有没有人发现如何将文本字段添加到PDF?

尝试使用pdfbox创建带有可由用户或计算机填写的表单字段的pdf.到目前为止我的代码看起来像这样:

PDDocument doc = new PDDDocument();
PDPage page = new PDPage();
doc.addPage(page)
PDAcroForm = new PDAcroForm(doc)
doc.documentCatalog.setAcroForm(acroForm)
COSDictionary cosDict = new COSDictionary()
PDTextbox textField = new PDTextbox(acroForm, cosDict)
PDRectangle rect = new PDRectangle()
rect.setLowerLeftX((float) 250)
rect.setLowerLeftY((float) 125)
rect.setUpperRightX((float) 500)
rect.setUpperRightY((float) 75)
textField.getWidget().setRectangle(rect)
acroForm.getFields.add(textField)
page.getAnnotations().add(textField)
page.getAnnotations().add(textField.getWidget())
Run Code Online (Sandbox Code Playgroud)

java pdfbox

3
推荐指数
1
解决办法
3047
查看次数

标签 统计

java ×1

pdfbox ×1