0

我正在尝试使用 java 展平 pdf 表单文件。我正在使用 PdfReader api。但是,我看到了这些特定的错误:

PdfReader cannot be resolved to a type
PdfStamper cannot be resolved to  a type
AcroFields cannot be resolved to a type .

谁能告诉我,我错过了什么罐子或发生这种情况的任何其他可能原因?

这是代码:

        import java.io.FileOutputStream;

        public class FormFillAndMakeItFlattenPDF {
            public static void main(String[] args) {
                try {
                    PdfReader reader = new PdfReader("SimpleRegistrationForm.pdf");
                    PdfStamper stamp2 = new PdfStamper(reader, new FileOutputStream("FormFillAndMakeItFlattenPDF.pdf"));
                    AcroFields form2 = stamp2.getAcroFields();
                    form2.setField("name", "your name");
                    form2.setField("address", "address");
                    form2.setField("postal_code", "code");
                    form2.setField("email", "youremail");
                    stamp2.setFormFlattening(true);
                    stamp2.close();
                }
                catch (Exception de) {
                    de.printStackTrace();
                }
            }
        }
4

0 回答 0