-1

I have a task to merge several PDFs into a single one. I'm using iTextSharp. The issue I'm having is the merging involves the same 1 page form filled out X numbers of times with different information. Once the PDFs are merged into one, the fields on all X of those pages have the same name, so any change to one alters all the others.

Is there a way I can alter the fields programatically as I go so they are truly distinct fields in the final PDF?

erosebe
  • 927
  • 3
  • 16
  • 31

1 Answers1

1

You can rename the fields before adding the pages with:

PdfReader reader = new PdfReader(src);
PdfStamper stamper = new PdfStamper(reader, new FileOutputStream(dest));
AcroFields form = stamper.getAcroFields();
form.renameField("personal.loginname", "personal.login");
stamper.close();
reader.close();
Paulo Soares
  • 1,896
  • 8
  • 21
  • 19
  • Thanks. For some reason I had trouble with this. I think it could have been made to work, if I changed the names first and then filled the fields using the new names. I found it easier to use Sola Oderinde's answer from this question, though. http://stackoverflow.com/questions/2343657/is-it-possible-to-modify-pdf-form-field-names – erosebe Jun 03 '15 at 18:20