Пример #1
0
// ---------------------------------------------------------------------------

        /**
         * Extracts text from a PDF document.
         * @param src the original PDF document
         */
        public string ExtractText(byte[] src)
        {
            PdfReader                 reader       = new PdfReader(src);
            MyTextRenderListener      listener     = new MyTextRenderListener();
            PdfContentStreamProcessor processor    = new PdfContentStreamProcessor(listener);
            PdfDictionary             pageDic      = reader.GetPageN(1);
            PdfDictionary             resourcesDic = pageDic.GetAsDict(PdfName.RESOURCES);

            processor.ProcessContent(
                ContentByteUtils.GetContentBytesForPage(reader, 1),
                resourcesDic
                );
            return(listener.Text.ToString());
        }
Пример #2
0
// ---------------------------------------------------------------------------    
    /**
     * Extracts text from a PDF document.
     * @param src the original PDF document
     */
    public string ExtractText(byte[] src) {
      PdfReader reader = new PdfReader(src);
      MyTextRenderListener listener = new MyTextRenderListener();
      PdfContentStreamProcessor processor = new PdfContentStreamProcessor(listener);
      PdfDictionary pageDic = reader.GetPageN(1);
      PdfDictionary resourcesDic = pageDic.GetAsDict(PdfName.RESOURCES);
      processor.ProcessContent(
        ContentByteUtils.GetContentBytesForPage(reader, 1), 
        resourcesDic
      );
      return listener.Text.ToString();
    }