Menu

#6 ClassCastException in pj.Pdf.java - appendPdfDocument( )

open
None
5
2006-03-27
2005-11-15
No

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

Discussion

  • Jean-Luc Hofman

    Jean-Luc Hofman - 2005-11-15

    PDF File with an "AcroForm" object

     
  • Nassib Nassar

    Nassib Nassar - 2006-03-27
    • assigned_to: nobody --> nnassar
     

Log in to post a comment.