PDFBOX:java.lang.NumberFormatException:
当我尝试执行下面的代码时,它抛出以下错误
java.lang.NumberFormatException: For input string: "8#40"
at java.lang.NumberFormatException.forInputString(Unknown Source)
编码:
import org.apache.pdfbox.pdmodel.PDDocument;
import org.apache.pdfbox.pdmodel.interactive.form.PDAcroForm;
import org.apache.pdfbox.pdmodel.interactive.form.PDField;
public class PDFPerform
{
public static void main(String[] args)
{
try{
String sourcePath = "C:\Users\347702\Desktop\fw4.pdf";
String destinationPath = "D:\PDF_FORMS\filled_fw4.pdf";
PDDocument document;
document = PDDocument.load(sourcePath);
PDAcroForm form = document.getDocumentCatalog().getAcroForm();
PDField Field_1= form.getField("f1_09(0)");
Field_1.getValue();
System.out.println(Field_1.getValue());
Field_1.setValue("asdsd");
System.out.println(Field_1.getFieldType());
}
catch(Exception e)
{
e.printStackTrace();
}
}
}
有谁能帮我找出上述问题的根本原因?
提到的字段f1_09(0)
是文本类型,但当我为其设置值时,会引发错误
谢谢
解决方案
在我将pdfbox.1.7.1
版本更新为pdfbox1.8.1.jar
后,它工作正常
相关文章