parser.ProcessContent(1, new SimpleTextExtractionStrategy());C#新人求救,改编于这个java代码,
http://blog.csdn.net/sishenkankan/article/details/53107195下面是报错信息:未处理System.ObjectDisposedException
  HResult=-2146232798
  Message=无法访问已关闭的文件。
  Source=mscorlib
  ObjectName=""
  StackTrace:
       在 System.IO.__Error.FileNotOpen()
       在 System.IO.FileStream.get_Position()
       在 iTextSharp.text.io.RAFRandomAccessSource.Get(Int64 position, Byte[] bytes, Int32 off, Int32 len)
       在 iTextSharp.text.io.IndependentRandomAccessSource.Get(Int64 position, Byte[] bytes, Int32 off, Int32 len)
       在 iTextSharp.text.pdf.RandomAccessFileOrArray.Read(Byte[] b, Int32 off, Int32 len)
       在 iTextSharp.text.pdf.RandomAccessFileOrArray.ReadFully(Byte[] b, Int32 off, Int32 len)
       在 iTextSharp.text.pdf.RandomAccessFileOrArray.ReadFully(Byte[] b)
       在 iTextSharp.text.pdf.PdfReader.GetStreamBytesRaw(PRStream stream, RandomAccessFileOrArray file)
       在 iTextSharp.text.pdf.PdfReader.GetStreamBytes(PRStream stream, RandomAccessFileOrArray file)
       在 iTextSharp.text.pdf.PdfReader.GetStreamBytes(PRStream stream)
       在 iTextSharp.text.pdf.parser.ContentByteUtils.GetContentBytesFromContentObject(PdfObject contentObject)
       在 iTextSharp.text.pdf.parser.ContentByteUtils.GetContentBytesFromContentObject(PdfObject contentObject)
       在 iTextSharp.text.pdf.parser.ContentByteUtils.GetContentBytesFromContentObject(PdfObject contentObject)
       在 iTextSharp.text.pdf.parser.ContentByteUtils.GetContentBytesForPage(PdfReader reader, Int32 pageNum)
       在 iTextSharp.text.pdf.parser.PdfReaderContentParser.ProcessContent[E](Int32 pageNumber, E renderListener, IDictionary`2 additionalContentOperators)
       在 iTextSharp.text.pdf.parser.PdfReaderContentParser.ProcessContent[E](Int32 pageNumber, E renderListener)

解决方案 »

  1.   

    就是不懂,看报错,好像执行到itext的dll里面的代码了
      

  2.   

    就是不懂,看报错,好像执行到itext的dll里面的代码了
    你原先的代码是:
    parser.ProcessContent(i,listener);
    你用1代替i,没有问题,但是你用new SimpleTextExtractionStrategy()代替listener出现了问题。
    new SimpleTextExtractionStrategy()类型没错,但是是一个全新的对象,listener应该之前有过处理。
      

  3.   

    就是不懂,看报错,好像执行到itext的dll里面的代码了
    你原先的代码是:
    parser.ProcessContent(i,listener);
    你用1代替i,没有问题,但是你用new SimpleTextExtractionStrategy()代替listener出现了问题。
    new SimpleTextExtractionStrategy()类型没错,但是是一个全新的对象,listener应该之前有过处理。这2个都试过,都是一样报错,listener是在上面一句定义的,
    PositionRenderListener listener = new PositionRenderListener(this.findText);
    parser.ProcessContent(1, listener);报错之后,
    然后用这个语句的,parser.ProcessContent(1, new SimpleTextExtractionStrategy());
      

  4.   

    这个Java代码可以自动找出字符所在的位置,没找到C#相关的代码
      

  5.   

    这个Java代码可以自动找出字符所在的位置,没找到C#相关的代码
    字符位置就是遍历而已吧?你参考一下C#是怎么加载资源的,后面拼下java的处理方法?java跟C#多少有些不同
      

  6.   

    这个Java代码可以自动找出字符所在的位置,没找到C#相关的代码
    字符位置就是遍历而已吧?你参考一下C#是怎么加载资源的,后面拼下java的处理方法?java跟C#多少有些不同
    不是字符查找,是字符所在页面位置的x,y坐标