0

I am looking for information about programing vba with Excel or Access for finding text and extracting text strings from pdf files. I cannot use Adobe because it needs a license and my company wont buy any. Therefore I've searched for other software to do this and I've found that Nuance Power PDF could be a good option. It has libraries to work with it.

The problem is that I can not find enough information about this interface on internet.

Here in this question of superuser and in this question of stackoverflow, @Shodan @HackSlash @DaniRecFR31 talks about a document called "Power PDF 2 Automation interface.doc" by Bence.Balazs@nuance.com

As I can not find more information about Power PDF in internet, I would like to know if anyone can tell me where to find that document.

Also, If someone knows about other software to work with pdf and vba would be appreciated

1

First of all I want to thanks @ComputerVersteher with his advice of using Xpdf. Unfortunately I can not use it neither because I am not allowed to install new software on my company's computer.

It was impossible to me to find that document on internet, I don't know the reason why. I kept searching and realized that Nuance Power PDF and Adobe has a very similar library. I am noob with Adobe tools and javascript, but I could do a full text extraction from a pdf starting with a solution with Adobe found on internet.

Using that solution for Adobe, I modified the parameters in order to make it work with Nuance Power PDF and get an array where each index contain the text of each page. The only thing I don't like is the the Carriage Return of each paragraph is not exported, but for my initial purpose is enough like this.

Sub test()
    Dim Path As String
    Path = "C:\Users\unername\Desktop\doc.pdf"
    TextInArray = ExtractTextFromPDF_WithNuancePowerPDF(Path)
End Sub

Function ExtractTextFromPDF_WithNuancePowerPDF(FullPath As String)
    Dim PowerApp As app
    Dim PowerDVDoc As DVDoc
    Dim PowerDDDoc As DDDoc
    Dim jso As Object

    Dim nPalabra As Integer
    Dim iPalabra As Integer
    Dim nPagina As Integer
    Dim iPagina As Integer
    Dim Palabra As String
    Dim TextoPagina() As String

    Set PowerApp = CreateObject("NuancePDF.App")
    Set PowerDVDoc = CreateObject("NuancePDF.DVDoc")
    PowerApp.Show

    If PowerDVDoc.Open(FullPath) = True Then
        PowerDVDoc.BringToFront
        Set PowerDDDoc = PowerDVDoc.GetDDDoc
        Set jso = PowerDDDoc.GetJSObject
        nPagina = PowerDDDoc.GetNumPages
        ReDim TextoPagina(nPagina)
        For iPagina = 0 To nPagina - 1
            nPalabra = jso.getPageNumWords(iPagina)
            For iPalabra = 0 To nPalabra - 1
                Palabra = jso.getPageNthWord(iPagina, iPalabra, False) ' if the last parameter is set to True, it avoids certain characters like dash os blank spaces etc
                TextoPagina(iPagina) = TextoPagina(iPagina) & Palabra
            Next
            Debug.Print TextoPagina(iPagina)
        Next
    End If
    Set PowerDVDoc = Nothing
    PowerApp.Exit
    Set PowerApp = Nothing
    ExtractTextFromPDF_WithNuancePowerPDF = TextoPagina
End Function

Now with the output of this Function, I can do a search of the specific text and extract other strings, So my initial needs are solved.

  • Help yourself and you will get helped ;) Nice. On point on xpdf tools. There is no installiation needed, just extract the zip and copy pdftotext.exe to any location and call it from shell. – ComputerVersteher Jul 4 at 12:03
  • hahahaha good to know about the portability of Xpdf. Anyway I cannot use it because we are not allowed to install new software neither download portable software. If we do it, IT security will cut my b... and they gave me alredy my first notification few days ago hahahaha – Joracosu Jul 4 at 12:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.