Setting
a) I have a reader extended XFA form (that contains 2 barcodes)
b) I have prepopulation XML
Intended Solution
- Prepopulate the XFA form with XML and then flatten the PDF (so that it is view-able in browsers, etc)
What's working
- Prepopulating of the XFA form is working and all fields & barcodes are populated as required (1 pager is generated) - looks perfect
The Problem / What's not working
- The second part of my code pickups the prepopulated PDF and then flattens the XFA form, the resultant pdf is now magically a 2 pager.
- The inbody barcode appears on the first page and all the other contents are incorrectly pushed to the second page.
- The positioning of all the elements are relatively correct, however split over two pages - they should all be on 1 page.
- The form & fields is flattened and views in a browser
For interest sake
I've 'flattened' the form using various forms of code, examples below
PDF FLATTENING CODE A
PdfReader reader = new PdfReader(src);
PdfStamper stamper = new PdfStamper(reader, new
FileOutputStream(dest));
stamper.setFormFlattening(true);
stamper.close();
PDF FLATTENING CODE B
Document document = new Document();
PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream(new File(dest)));
XFAFlattener xfaf = new XFAFlattener(document, writer);
xfaf.flatten(new PdfReader(fileToByteArray(src)));
document.close();
QUESTIONS
- Am I perhaps using the wrong 'flattening' code?
- Has any body experienced something similar?
- Why is this happening
- How can this be solved
Super appreciate any input here.
REF: SUP-1858