public void copyAcroForm ( PdfReader reader ) throws IOException , BadPdfFormatException { setFromReader ( reader ) ; PdfDictionary catalog = reader . getCatalog ( ) ; PRIndirectReference hisRef = null ; PdfObject o = catalog . get ( PdfName . ACROFORM ) ; if ( o != null && o . type ( ) == PdfObject . INDIRECT ) hisRef = ( PRIndirectReference ) o ; if ( hisRef == null ) return ; // bugfix by John Englar RefKey key = new RefKey ( hisRef ) ; PdfIndirectReference myRef ; IndirectReferences iRef = ( IndirectReferences ) indirects . get ( key ) ; if ( iRef != null ) { acroForm = myRef = iRef . getRef ( ) ; } else { acroForm = myRef = body . getPdfIndirectReference ( ) ; iRef = new IndirectReferences ( myRef ) ; indirects . put ( key , iRef ) ; } if ( ! iRef . getCopied ( ) ) { iRef . setCopied ( ) ; PdfDictionary theForm = copyDictionary ( ( PdfDictionary ) PdfReader . getPdfObject ( hisRef ) ) ; addToBody ( theForm , myRef ) ; } }
Copy the acroform for an input document . Note that you can only have one we make no effort to merge them .