static public void listContentStreamForPage ( PdfReader reader , int pageNum , PrintWriter out ) throws IOException { out . println ( "==============Page " + pageNum + "====================" ) ; out . println ( "- - - - - Dictionary - - - - - -" ) ; PdfDictionary pageDictionary = reader . getPageN ( pageNum ) ; out . println ( getDictionaryDetail ( pageDictionary ) ) ; out . println ( "- - - - - Content Stream - - - - - -" ) ; RandomAccessFileOrArray f = reader . getSafeFile ( ) ; byte [ ] contentBytes = reader . getPageContent ( pageNum , f ) ; f . close ( ) ; InputStream is = new ByteArrayInputStream ( contentBytes ) ; int ch ; while ( ( ch = is . read ( ) ) != - 1 ) { out . print ( ( char ) ch ) ; } out . println ( "- - - - - Text Extraction - - - - - -" ) ; PdfTextExtractor extractor = new PdfTextExtractor ( reader ) ; String extractedText = extractor . getTextFromPage ( pageNum ) ; if ( extractedText . length ( ) != 0 ) out . println ( extractedText ) ; else out . println ( "No text found on page " + pageNum ) ; out . println ( ) ; }
Writes information about a specific page from PdfReader to the specified output stream .