PdfStream getFormXObject ( int pageNumber , int compressionLevel ) throws IOException { PdfDictionary page = reader . getPageNRelease ( pageNumber ) ; PdfObject contents = PdfReader . getPdfObjectRelease ( page . get ( PdfName . CONTENTS ) ) ; PdfDictionary dic = new PdfDictionary ( ) ; byte bout [ ] = null ; if ( contents != null ) { if ( contents . isStream ( ) ) dic . putAll ( ( PRStream ) contents ) ; else bout = reader . getPageContent ( pageNumber , file ) ; } else bout = new byte [ 0 ] ; dic . put ( PdfName . RESOURCES , PdfReader . getPdfObjectRelease ( page . get ( PdfName . RESOURCES ) ) ) ; dic . put ( PdfName . TYPE , PdfName . XOBJECT ) ; dic . put ( PdfName . SUBTYPE , PdfName . FORM ) ; PdfImportedPage impPage = ( PdfImportedPage ) importedPages . get ( Integer . valueOf ( pageNumber ) ) ; dic . put ( PdfName . BBOX , new PdfRectangle ( impPage . getBoundingBox ( ) ) ) ; PdfArray matrix = impPage . getMatrix ( ) ; if ( matrix == null ) dic . put ( PdfName . MATRIX , IDENTITYMATRIX ) ; else dic . put ( PdfName . MATRIX , matrix ) ; dic . put ( PdfName . FORMTYPE , ONE ) ; PRStream stream ; if ( bout == null ) { stream = new PRStream ( ( PRStream ) contents , dic ) ; } else { stream = new PRStream ( reader , bout , compressionLevel ) ; stream . putAll ( dic ) ; } return stream ; }
Gets the content stream of a page as a PdfStream object .