Class : com.etymon.pj.Pdf
The method appendPdfDocument(Pdf pdf) gets a
reference to the "AcroForm" of the document to append
in variable <otherAcroForm>
(line 503)
On line 600, in case there is no "AcroForm" in the first
document, it gets again a reference to the "Acroform" of
the document to
append.
At this time, the call (PjDictionary)
(otherCatalog.getAcroForm()) lacks a call to resolve(),
which results in a ClassCastException.
If we call
PjDictionary otherAf = (PjDictionary)(pdf.resolve
(otherCatalog.getAcroForm()));
we don't get the ClassCastException, but we get a
reference to an object which is not necessarily
the "AcroForm".
There has been a remapping earlier in the method, and
the number of the object we get is not the same as the
one we got at the
beginning of the method.
My suggestion is to use the reference in
<otherAcroForm> instead of trying to get again the
reference to the "AcroForm"
The resulting code :
//PjDictionary otherAf = (PjDictionary)
(otherCatalog.getAcroForm());
if (otherAcroForm != null) {
//catalog.setAcroForm(otherAf);
catalog.setAcroForm(otherAcroForm);
}
To experience the problem, append the attached PDF
file to a PDF without any AcroForm
PDF File with an "AcroForm" object