Using pdfbox to get form field values

前端 未结 2 1850
隐瞒了意图╮
隐瞒了意图╮ 2021-02-11 02:11

I\'m using pdfbox for the first time. Now I\'m reading something on the website Pdf

Summarizing I have a pdf like this:

2条回答
  •  执念已碎
    2021-02-11 02:45

    The code you have should work. If you are actually looking to do something with the values, you'll likely need to use some other methods. For example, you can get specific fields using pdAcroForm.getField():

    PDField firstNameField = pdAcroForm.getField("firstName");
    PDField lastNameField = pdAcroForm.getField("lastName");
    

    Note that PDField is just a base class. You can cast things to sub classes to get more interesting information from them. For example:

    PDCheckbox fullTimeSalary = (PDCheckbox) pdAcroForm.getField("fullTimeSalary");
    if(fullTimeSalary.isChecked()) {
        log.debug("The person earns a full-time salary");
    } else {
        log.debug("The person does not earn a full-time salary");
    }
    

    As you suggest, you'll find more information at the apache pdfbox website.

提交回复
热议问题