/** * Writes information about a specific page from PdfReader to the specified output stream. * @since 2.1.5 * @param reader the PdfReader to read the page content from * @param pageNum the page number to read * @param out the output stream to send the content to * @throws IOException */ public static void ListContentStreamForPage(PdfReader reader, int pageNum, TextWriter outp) { outp.WriteLine("==============Page " + pageNum + "===================="); outp.WriteLine("- - - - - Dictionary - - - - - -"); PdfDictionary pageDictionary = reader.GetPageN(pageNum); outp.WriteLine(GetDictionaryDetail(pageDictionary)); outp.WriteLine("- - - - - XObject Summary - - - - - -"); outp.WriteLine(GetXObjectDetail(pageDictionary.GetAsDict(PdfName.RESOURCES))); outp.WriteLine("- - - - - Content Stream - - - - - -"); RandomAccessFileOrArray f = reader.SafeFile; byte[] contentBytes = reader.GetPageContent(pageNum, f); f.Close(); outp.Flush(); foreach (byte b in contentBytes) { outp.Write((char)b); } outp.Flush(); outp.WriteLine("- - - - - Text Extraction - - - - - -"); String extractedText = PdfTextExtractor.GetTextFromPage(reader, pageNum, new LocationTextExtractionStrategy()); if (extractedText.Length != 0) { outp.WriteLine(extractedText); } else { outp.WriteLine("No text found on page " + pageNum); } outp.WriteLine(); }