I'm using LibreOffice 4.1.3.2 to produce a fillable PDF:
- Created a Writer document
- Set some text and test fields
- Exported to PDF
Opening pdf file with Acrobar Reader shows a correct fillable pdf.
Next I use iTextSharp 5.4.5 to fill fields and save flattened document:
var pdf = new PdfReader(srcFilename);
using (var fw = new FileStream(dstFilename, FileMode.Create))
{
var stamper = new PdfStamper(pdf, fw);
var f = stamper.AcroFields;
f.SetField("field1", "John Doe");
f.SetField("field2", "12/04/2013");
stamper.FormFlattening = true;
stamper.Close();
}
pdf.Close();
Problem is that filled fields values completely disappear in new document!
I thought fields were not found or filled, but discovered that commenting stamper.FormFlattening = true
field values are there in saved pdf!!
Naturally I need a flattened pdf...
Is there a solution for this?
f.GenerateAppearances = true;
must be set before filling fields, or it's useless... – Horehound