Hello, thanks for all your effort with PDFBox. We use it heavily for parsing and flattening PDFs.
BUG: In the attached PDF "resetboundingbox.pdf", we programmatically set the value of the text fields, then call pdAcroForm.flattten(), which produces the flattened PDF "flattenedboundingbox.pdf." I would expect that the text would entirely fill the text box (see textbox with green border in "flattenedboundingbox.pdf") but the text does not. Instead, the filled text area obeys another box instead (see text area with red border in "flattenedboundingbox.pdf").
POTENTIAL FIX: We've traced the problem to AppearanceGeneratorHelper.setAppearanceValue, lines 200-210. As long as we always set the bounding box (line 243) like in AppearanceGeneratorHelper.prepareNormalAppearanceStream, regardless of the if/else at line 200, then the flattening works correctly:
Something I'm not sure about: in method prepareNormalAppearanceStream, there is additional code for setting the matrix (lines 245-251), which we don't seem to need. Since it doesn't break anything, we just keep it too.
Thanks again for your help!