VBA convert or transfer pdf file to text file.

I am using Access 2010.I have pdf file that have a table look data in. I need to covert or transfer that pdf file in text file using VBA and then import it in Access db without Adobe Acrobat installed on pc  and not using 3th party software.
If it is possible through VBA and how?
TarasAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Scott McDaniel (Microsoft Access MVP - EE MVE )Infotrakker SoftwareCommented:
No, it's not possible through VBA. VBA has no builtin capabilities to do that, so you'd have to have some form of 3rd party software, Abode or otherwise, to do this.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Nick67Commented:
No dice.
Installing Acrobat gets you some libraries that VBA can use to do fun things with PDFs
.NET can create PDF without external references -- I've built ASP.NET pages that do that -- so I presume that you could use Visual Studio to build your own dll to reverse that process and suck content out of a PDF whose structure you understand, but...

straight VBA to open and convert PDFs?

Nope.  Not happening.
TarasAuthor Commented:
thanks a lot.
IT Pros Agree: AI and Machine Learning Key

We’d all like to think our company’s data is well protected, but when you ask IT professionals they admit the data probably is not as safe as it could be.

Scott McDaniel (Microsoft Access MVP - EE MVE )Infotrakker SoftwareCommented:
.NET can create PDF without external references
Can you explain that a bit more? I'm curious how to do that in .NET, since I often create PDFs in .NET and would love to not deploy anything to do that.
Nick67Commented:
There's the free iTextSharp library

Here's the guts of the code.
Note this is for reference.
It's not nearly workable in this format for you -- but the ideas and keywords to Google to there
The iTextSharp documentation for .Net is pretty sparse, but basically you create a document and add paragraphs, tables and images to it.  you close the writer and document and then redirect the browser to the newly written PDF.
It took me quite a while to wrap my head around the persnickety syntax -- and generating a chart as an image to be added -- but it works very well

Imports iTextSharp.text
Imports iTextSharp.text.pdf

    Protected Function BuildUTReadingsPDF() As String
        Dim TheDoc As New Document(PageSize.LETTER.Rotate, 18, 18, 18, 18)
        Dim url As String = "usr/UT" & Now.ToFileTime & ".pdf"

        'also stymied on usercontrol placeholder repeater updatepanel problem
        'placeholder control gets no intellisense on the update panel

        Dim TheFinalFile As New FileStream(Server.MapPath(url), FileMode.Create)
        Dim TheWriter = PdfWriter.GetInstance(TheDoc, TheFinalFile)

        Dim titleFont = FontFactory.GetFont("Tahoma", 10, iTextSharp.text.Font.BOLD)
        Dim headFont = FontFactory.GetFont("Tahoma", 10)
        Dim subtitleFont = FontFactory.GetFont("Tahoma", 9, iTextSharp.text.Font.BOLD)
        Dim detailFont = FontFactory.GetFont("Tahoma", 8)
        Dim GridheadFont = FontFactory.GetFont("Tahoma", 8, iTextSharp.text.Color.WHITE)
        Dim GridFont = FontFactory.GetFont("Tahoma", 8, iTextSharp.text.Color.BLACK)
        'All right All right All righht!
        'It creates and opens a PDF
        ' Now to get it to be the same as the report! 
        Dim paraClient As New Paragraph("Client Name", titleFont)
        Dim paraName As New Paragraph(Me.theClientName.Text)
        Dim mytable = New iTextSharp.text.Table(UTReadings.Columns.Count)
        mytable.Cellpadding = 2
        mytable.Width = 100
        'Set the column widths
        'in points
        '72 points to the inch
        'I've tried various fiddle-farts to do this dynamically
        'because the gridview is dynamic, you can't crank around its widths
        'they evaluate as zero
        'so I coded them
        Dim TheWidths As Integer() = New Integer(UTReadings.Columns.Count - 1) {}
        TheWidths(0) = 45
        TheWidths(1) = 60
        TheWidths(2) = 60
        TheWidths(3) = 50
        TheWidths(4) = 21
        TheWidths(5) = 21
        TheWidths(6) = 21
        TheWidths(7) = 21
        TheWidths(8) = 21
        TheWidths(9) = 21
        TheWidths(10) = 21
        TheWidths(11) = 21
        TheWidths(12) = 85
        TheWidths(13) = 85
        TheWidths(14) = 35
        TheWidths(15) = 35


        'Transfer rows from GridView to table
        For i As Integer = 0 To UTReadings.Columns.Count - 1
            Dim cellText As String = Server.HtmlDecode(UTReadings.Columns(i).HeaderText)
            Dim cell As New Cell(New Phrase(cellText, GridheadFont))
            cell.BackgroundColor = New iTextSharp.text.Color(System.Drawing.ColorTranslator.FromHtml("#000080"))

            mytable.AddCell(cell)
        Next

        For i As Integer = 0 To UTReadings.Rows.Count - 1
            If UTReadings.Rows(i).RowType = DataControlRowType.DataRow Then
                For j As Integer = 0 To UTReadings.Columns.Count - 1
                    Dim cellText As String = Server.HtmlDecode(UTReadings.Rows(i).Cells(j).Text)
                    'Dim cell As New iTextSharp.text.Cell(cellText)
                    Dim cell As New Cell(New Phrase(cellText, GridFont))
                    'Set Color of Alternating row
                    If i Mod 2 <> 0 Then
                        cell.BackgroundColor = New iTextSharp.text.Color(System.Drawing.ColorTranslator.FromHtml("#DCDCDC "))
                    End If
                    mytable.AddCell(cell)
                Next
            End If
        Next

        For i As Integer = 0 To UTReadings.Columns.Count - 1
            Dim cellText As String = String.Empty 'TheWidths(i).ToString
            Dim cell As New Cell(New Phrase(cellText, GridheadFont))
            cell.BackgroundColor = New iTextSharp.text.Color(System.Drawing.ColorTranslator.FromHtml("#000080"))
            mytable.AddCell(cell)
        Next
        mytable.SetWidths(TheWidths)
        Dim clsTheHeaderImage As New clsHeaderImage
        Dim TheHeaderImage = clsTheHeaderImage.TheHeaderImage
        TheHeaderImage.ScaleToFit(216, 36)
        TheHeaderImage.SetAbsolutePosition(TheDoc.PageSize.Width - 18 - (3 * 72), TheDoc.PageSize.Height - 54)
        TheDoc.Open()
        With TheDoc
            .Add(paraClient)
            .Add(paraName)
            .Add(mytable)
            If clsTheHeaderImage.Gronk.ToString = String.Empty Then
                .Add(TheHeaderImage)
            Else
                Dim theGronk As New Paragraph(clsTheHeaderImage.Gronk)
                .Add(theGronk)
            End If
        End With

        TheDoc.Close()
        TheWriter.Close()

        'testing code kicks this out to new window
        'Dim script As String = "window.open(""{0}"", ""{1}"");"
        'url = Page.ResolveClientUrl(url)
        'script = String.Format(script, url, "_blank")
        'ScriptManager.RegisterClientScriptBlock(Page, GetType(Page), "Redirect", script, True)

        BuildUTReadingsPDF = url



    End Function

Open in new window

Scott McDaniel (Microsoft Access MVP - EE MVE )Infotrakker SoftwareCommented:
Hmmm .... I was hoping I'd overlooked something in the .NET Framework, but iTextSharp is just like Adobe, PDFSHarp, etc (i.e. it's a 3rd party/external reference, which means it must be deployed to the target machine).

I use PDFSharp, which is very much like iTextSharp (and I believe is an offshoot), so unfortunately I'd be in the same boat with iTextSharp (i.e. I'd have to deploy that 3rd party library, just as I do with PDFSharp).
Nick67Commented:
We're in different boats.
I wear all the hats and it's for my outfit, so deployment on our own server wasn't that painful to start with.
The dll is 3.6 MB

Sorry to have gotten your hopes up :(
Scott McDaniel (Microsoft Access MVP - EE MVE )Infotrakker SoftwareCommented:
Right, but you're still using an external reference. The iTextSharp library isn't part of the .NET Framework, so the machine still must have the correct libraries installed (regardless of the size). Once you've done that, you can then set the reference and use the Imports statement as you've done.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Access

From novice to tech pro — start learning today.