Click here to Skip to main content
15,885,278 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
hi everyone

i would like some help with the application that we developed.
this is for our office use only, and what our app is doing is extracting the text from the pdf file using pdflibnet.dll

but we lately encountered a problem with a particular pdf file.
the problem is when we try to pdfdoc.load(strFileLocation) there is an error.
below is the sample code/function that we have so far.

And System.IO.File.Delete(TempFile) will stop the application from running.

"The process cannot access the file 'D:\temp\test2.pdf' because it is being used by another process."

i would like to attach the pdf file but here but there is no way for me to attch it here.

so here is the DL link from other fileservers.

http://www.rarefile.net/esbjcrhn4iek/test.pdf[^]


VB
Public Function ExtractPDF(ByVal strl_File As String) As String
       Dim strl_RetVal As String = ""

       Dim TempFile As String = System.IO.Path.GetTempPath & Now.Ticks & ".txt"
       

       Dim pdfdoc As PDFLibNet.PDFWrapper = New PDFLibNet.PDFWrapper
       Dim pagecount As Integer = 0
       Try

           pdfdoc.LoadPDF(strl_File)
           pagecount = pdfdoc.PageCount
             pdfdoc.ExportText(TempFile, 1, pagecount, True, True)
            If File.Exists(TempFile) Then
                strl_RetVal = System.IO.File.ReadAllText(TempFile)
                System.IO.File.Delete(TempFile)
            End If

            strl_RetVal = RemoveWhitespace(strl_RetVal) ' Remove white space
          Catch aveEx As System.AccessViolationException
          MsgBox(aveEx.Message)
         Finally
            'release object from memory
            pdfdoc.Dispose()
            'releaseObject(pdfdoc)
        End Try
    Return strl_RetVal
    End Function
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900