Unable to read text from memory stream

All,

The code below will extract all text from my pdf file and save it to a text file. However, if I just to message out the content of the sr variable below, all I get is the first character of the pdf file. This probably something basic but I was hoping this forum could help me get past this issue.

Dim license As Aspose.Pdf.Kit.License = New Aspose.Pdf.Kit.License

license.SetLicense("Aspose.Pdf.Kit.lic")

'Instantiate PdfExtractor object

Dim extractor As PdfExtractor = New PdfExtractor()

extractor.ExtractTextMode = 0

' Instantiate a memoryStream object to hold the extracted text from Document

Dim ms As New MemoryStream()

'Set Password for input PDF file

extractor.Password = ""

'Bind the input PDF document to extractor

extractor.BindPdf("c:\myPDFDoc.pdf")

'Extract text from the input PDF document

extractor.ExtractText()

'Save the extracted text memorystream

extractor.GetText(ms)

ms.Seek(0, SeekOrigin.Begin)

Dim sr As New StreamReader(ms, True)

MsgBox(sr.ReadToEnd())

ms.Close()

sr.Close()

Hi Rafael,

Please try to use the code snippet shown on this link to extract the text from PDF file. If you still find any issues, please share the sample PDF file with us, so we could test the issue at our end.

We’re sorry for the inconvenience.
Regards,

Thanks! That worked for me.