Flatten or Merge PDF with PDFBox
-
Hi all, I'm having an issue with PDFBox (1.3.1) - I'm using a PDF with AcroForms to basically pull off a 'mail merge'. I am successfully populating the fields with data, but what I want to do now is 'render it down' or 'flatten' it. I don't want these fields to be editable in the final result. (not entirely sure I'm communicating my intention clearly here, let me know if clarification is needed) I've found this post that says to "remove all fields from [the] acroform". I've tried this in a number of ways:
pdfAcroForm.getFields().clear();
and...
pdfAcroForm.setFields(new ArrayList());
and...
Iterator fields = pdfAcroForm.getFields().iterator();
while (fields.hasNext())
{
PDField field = (PDField)fields.next();
field.setAcroForm(null);
}and variations thereof...
while typing this I thought to try:
pdfAcroForm.setFields(new COSArrayList());
maybe that will fix it?
Anyway, does anyone know how to do this? I have this niggling feeling that it's a language barrier (I'm a native C# speaker). I also have a niggling feeling that the aforementioned article is a big red herring that's taken me down the road to the dark side... Any help would be MUCH appreciated :)
-
Hi all, I'm having an issue with PDFBox (1.3.1) - I'm using a PDF with AcroForms to basically pull off a 'mail merge'. I am successfully populating the fields with data, but what I want to do now is 'render it down' or 'flatten' it. I don't want these fields to be editable in the final result. (not entirely sure I'm communicating my intention clearly here, let me know if clarification is needed) I've found this post that says to "remove all fields from [the] acroform". I've tried this in a number of ways:
pdfAcroForm.getFields().clear();
and...
pdfAcroForm.setFields(new ArrayList());
and...
Iterator fields = pdfAcroForm.getFields().iterator();
while (fields.hasNext())
{
PDField field = (PDField)fields.next();
field.setAcroForm(null);
}and variations thereof...
while typing this I thought to try:
pdfAcroForm.setFields(new COSArrayList());
maybe that will fix it?
Anyway, does anyone know how to do this? I have this niggling feeling that it's a language barrier (I'm a native C# speaker). I also have a niggling feeling that the aforementioned article is a big red herring that's taken me down the road to the dark side... Any help would be MUCH appreciated :)
[Caveat - I am not familiar with API you are using] You should not need to remove the form fields. The pdf document allows itself to be locked, once locked the fields become ineditable.
Panic, Chaos, Destruction. My work here is done. or "Drink. Get drunk. Fall over." - P O'H OK, I will win to day or my name isn't Ethel Crudacre! - DD Ethel Crudacre