作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在使用 PDFBox 库来设置 PDF 中的值。
代码块通过我试图在列表框中设置值
public class App {
public static void main(String[] args) {
App app = new App();
app.test();
}
public void test(){
try {
InputStream resource = getClass().getResourceAsStream("/2.pdf");
PDDocument pdfDocument = PDDocument.load(resource);
PDDocumentCatalog docCatalog = pdfDocument.getDocumentCatalog();
PDAcroForm acroForm = docCatalog.getAcroForm();
PDListBox listBox = (PDListBox) acroForm.getField("multiple_listbox");
List<String> list = Arrays.asList("option 2", "option 1");
System.out.println("Set value in listBox: " + list);
listBox.setValue(list);
System.out.println("Get Value from list box: " + listBox.getValue());
pdfDocument.save("pdfupdate.pdf");
pdfDocument.close();
} catch (Exception e) {
e.printStackTrace();
}
}
结果显示仅从List<String>
中选择了第一个值PDF 格式。
在这里检查结果:
如何设置在 PDF 中选择的多个值?
PDFBox版本:2.0.6
来源pdf:https://www.dropbox.com/s/5cbicbuwu0kjwlq/2.pdf?dl=0
最佳答案
这是 PDFBox 2.0.6 之前的错误,已在问题 PDFBOX-3828 中修复。 。该修复将在 2.0.7 版本中进行,预计将于 2017 年夏末/秋季发布。对于那些等不及的人,请获取 snapshot version在这里(在该网页的底部)。
关于java - 如何在PDFBox中为PDListBox设置多个选项?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44456172/
我是一名优秀的程序员,十分优秀!