How to click a button in PDF form with iText? -
i have fill pdf form data. form contains few tables "add" button adds new row inputs table, example "foreign patent documents". need "click" button in code using itext few times, add necessary rows, input names there , fill them. how can itext? provide me code example?
my pdf file form https://drive.google.com/open?id=0bwtwu1543ebtq3a3b2dzcw9qyk0
this file predefined , can't regenerate it.
you don't "click" button programmatically. provide data necessary, , form adapt.
see fillxfa example. have purchase_order.pdf looks this:
this document has "add item" button add more line items (which results in creating more pages if necessary). button makes sense if there's gui, when fill out form programmatically, there aren't buttons push. provide xml data (e.g. data.xml), this:
public void manipulatepdf(string src, string dest) throws ioexception, documentexception { pdfreader reader = new pdfreader(src); pdfstamper stamper = new pdfstamper(reader, new fileoutputstream(dest)); acrofields form = stamper.getacrofields(); xfaform xfa = form.getxfa(); xfa.fillxfaform(new fileinputstream(xml)); stamper.close(); reader.close(); }
the result looks this: purchase_order_filled.pdf
as can see, multiple lines added, without pushing button.
important: see have hybrid document. think should make pure xfa form. code won't work if keep acroform fields.
Comments
Post a Comment