I have some data which I want to save in a pdf file. I don't want to create a pdf from source code. A client gives me many different templates and I want to fill these with data which he needs. For example I have an information about "name", "surname", "address", "phone number" etc. A client gives me a template where there are columns only for "name", "surname", he doesn't care about "address" and "phone number".
I've tried something like this(from: Creating complex pdf using java)
PdfReader reader = new PdfReader("C:/folder/template/template.pdf");
PdfStamper stamper = new PdfStamper(reader, new FileOutputStream("C:/folder/template/filledTemplate.pdf"));
AcroFields form = stamper.getAcroFields();
boolean column = form.setField("column", "insert data");
boolean key = form.setField("key", "insert key");
boolean value = form.setField("value", "insert value");
stamper.setFormFlattening(true);
stamper.close();
reader.close();
The problem is it doesn't do anything. A form variable is null. I don't have any requirements about tools. It doesn't need to be itext, It can be PDFBox(which I haven't used yet). Example pdf file: pdf file
Edit: I've just asked my colleague about this. Sorry for my mistake, we have some data in our application and I'm doing a converter to various types of files like excel or pdf. We have many columns so there's no problem with excel files but I can't put all data in pdf. So one of the solution is a client would choose a specific form of pdf with columns which he needs and he gets a pdf filled with data. So wee need different templates.