0

we have an editable PDF which contains number of TextFields and other Fields where the user can enter the values into PDF form. For some Fields we need to pre populate the values while displaying the PDF to the user. we display the PDF by reading as OutputStream and render it to the browser as embedded. we are using iText APIs such as PdfStamper to manipulate the PDF. we do not know the names of each fields in the PDF because it is generated by someone else. Is there any possibility to find the TextField based on the Key name before the Text box? for example Patient Name : Textbox, we want to assign values to TextBox based on Patient Name as key

If it is possible then we can find the appropriate Field based on the Key and assign the values to the Fields.

MKS Raja
  • 21
  • 6
  • By "key" do you mean the text label that happens to be near the field? – Chris Haas Jul 15 '14 at 13:29
  • we can assign values using setField method of PDFStamper as below PdfStamper pdfStamper = new PdfStamper(pdfReader, buffer); pdfStamper.getAcroFields().setField("Patient Name", "ABC"); – MKS Raja Jul 15 '14 at 13:31
  • Yes Chris Haas. Thanks for your interest to help us – MKS Raja Jul 15 '14 at 13:33
  • The "label" is part of the content stream. The "key" is the name of the field. You are confusing the "label" with the "key". When using the `setField()` method you need to use the key. Is "Patient Name" the key or the label? If you don't know the answer to this question, you need to share your PDF. – Bruno Lowagie Jul 16 '14 at 07:54
  • Yes Bruno Lowagie you are right. In our case it seems the Label is assigned as Key, that's why when I give the label using setField and it is filling the values in the PDF. If the label and key is different then I don't know how to assign the values using the label. Can you please share your thoughts on it I could retrieve all the keys using Map fields = acroFields.getFields(); Set keys = fields.keySet(); – MKS Raja Jul 16 '14 at 09:32

0 Answers0