Imports iTextSharp.text
Imports iTextSharp.text.pdf
Imports System.IO
Partial Public Class WebForm2
Inherits System.Web.UI.Page
Dim path As String = Server.MapPath("PDFs")
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
If GetTextFromPDF(path + "/AOTD_SU_20131118_006.pdf") <> "" Then
Me.Label1.Text = GetTextFromPDF(path + "/AOTD_SU_20131118_006.pdf")
Else
Me.Label1.Text = "The PDF has Images"
End If
End Sub
Public Shared Function GetTextFromPDF(ByVal PdfFileName As String) As String
Dim oReader As New iTextSharp.text.pdf.PdfReader(PdfFileName)
Dim i As Integer
Dim sOut = ""
For i = 1 To oReader.NumberOfPages
Dim its As New iTextSharp.text.pdf.parser.SimpleTextExtractionStrategy
sOut &= iTextSharp.text.pdf.parser.PdfTextExtractor.GetTextFromPage(oReader, i, its)
Next
Return sOut
End Function
End Class