CodePudding user response:
To solve the,,CodePudding user response:
Have not used itext7, you can see the arc adobe PDF reader apis,CodePudding user response:
Javax.xml.parsers. DocumentBuilderFactory. SetFeature (Ljava/lang/String; Z) V is excuse me this mistake how to solve theTry {
Map
Params. Put (" fill_15 ", "test");
PdfDocument PDF=new PdfDocument (new PdfReader (templatePath), new PdfWriter (newPDFPath));
If (params!=null & amp; & ! Params. IsEmpty ()) {//a parameter to replace
PdfAcroForm form=PdfAcroForm. GetAcroForm (PDF, true);
Map
For (String param: params keySet ()) {
PdfFormField formField=fields. The get (param);//get a certain form fields
If (formField!=null) {
//formField. SetFont (getDefaultFont ()). The setValue (params. Get (param));//replacement value
FormField. SetValue (params. Get (param));//replacement value
}
}
//form. FlattenFields ();//locking form, don't let change
}
PDF. The close ();
} the catch (Exception e) {
e.printStackTrace();
}