Results 1 to 9 of 9

Thread: Help reading a PDF

  1. #1

    Thread Starter
    New Member
    Join Date
    Dec 2012
    Location
    Wayne, NJ USA
    Posts
    3

    Question Help reading a PDF

    Hello.

    I'm new here.
    I've been asked to modify code that reads an XML file to also read a PDF (the source data can come in either format).
    I'm working with VB5 and Adobe Acrobat 9 Pro.

    I've been searching the web for examples and clues, but I see many different approaches.
    Please advise on the easiest way to read a PDF.

  2. #2
    Frenzied Member
    Join Date
    May 2006
    Location
    some place in the cloud
    Posts
    1,886

    Re: Help reading a PDF

    You could use the AcroPDF.dll
    It's a PDF viewer that you can place in a form of your project
    You'll find a lot of information if you google VB6 & AcroPDF
    JG


    ... If your problem is fixed don't forget to mark your threads as resolved using the Thread Tools menu ...

  3. #3
    gibra
    Guest

    Re: Help reading a PDF

    What does it mean to 'read' PDF?
    If you just need to 'view' the PDF file then you simply use the appropriate system function ShellExecute, indicating "open" in the parameter lpOperation:
    http://allapi.mentalis.org/apilist/ShellExecute.shtml

    If you distribute your applications keep in mind that:
    1) no guarantees that the user's system is installed Acrobat (could have Foxit Reader or another viewer) for which the ShellExecute function is strongly recommended because it will use the viewer installed, it does not matter what it is.

    2) ShellExecute is a system function present in all Windows versions, so nothing OCX / DLL to distribute and install, which they bring with them always the 'usual' version compatibility issues.

  4. #4
    PowerPoster Keithuk's Avatar
    Join Date
    Jan 2004
    Location
    Staffordshire, England
    Posts
    2,236

    Re: Help reading a PDF

    As gibra says the easiest way is to use the ShellExecute API but the user will have to have an Acrobat Reader installed as it uses the default app to open a pdf file.

    The ShellExecute is a very powerful API as it can do many things, open files, print files and email.
    Keith

    I've been programming with VB for 25 years. Started with VB4 16bit Pro, VB5 Pro, VB6 Pro/Enterprise and now VB3 Pro. But I'm no expert, I'm still learning.

  5. #5

    Thread Starter
    New Member
    Join Date
    Dec 2012
    Location
    Wayne, NJ USA
    Posts
    3

    Re: Help reading a PDF

    Quote Originally Posted by gibra View Post
    What does it mean to 'read' PDF?
    Specifically I need to open it, read each line, extract data from it, just like we already do from an XML file.

  6. #6
    gibra
    Guest

    Re: Help reading a PDF

    Quote Originally Posted by o1sowise View Post
    Specifically I need to open it, read each line, extract data from it, just like we already do from an XML file.
    Then you should use the Acrobat and PDF Library
    http://livedocs.adobe.com/acrobat_sd...nce/index.html

  7. #7

    Thread Starter
    New Member
    Join Date
    Dec 2012
    Location
    Wayne, NJ USA
    Posts
    3

    Re: Help reading a PDF

    Quote Originally Posted by gibra View Post
    Then you should use the Acrobat and PDF Library
    http://livedocs.adobe.com/acrobat_sd...nce/index.html
    ... in VB, not C???

  8. #8
    gibra
    Guest

    Re: Help reading a PDF

    Quote Originally Posted by o1sowise View Post
    ... in VB, not C???
    You need to download SDK, will found a lot of sample for many languages:
    http://livedocs.adobe.com/acrobat_sd...ccessible=true

  9. #9
    New Member
    Join Date
    Apr 2013
    Posts
    1

    Re: Help reading a PDF

    Hi,

    I use this code to view my PDFs from Excel:

    Option Explicit
    Private Declare Function ShellExecute Lib "shell32.dll" _
    Alias "ShellExecuteA" (ByVal hwnd As Long, ByVal lpszOp As String, _
    ByVal lpszFile As String, ByVal lpszParams As String, _
    ByVal LpszDir As String, ByVal FsShowCmd As Long) _
    As Long

    Const SW_SHOWNORMAL = 1

    Sub OpeninPDFannotator()
    Dim strPath, strParam As String
    strPath = ThisWorkbook.Path & "\Resources\test.pdf"
    strParam = Chr(34) & strPath & Chr(34) & " /page=15" & Chr(34)
    Call ShellExecute(0&, "open", "C:\Program Files (x86)\PDF Annotator\pdfannotator.exe", strParam, "", SW_SHOWNORMAL)
    Excel.Application.Visible = msoTrue
    End Sub

    "Excel.Application.Visible = msoTrue" does not work because the code does not wait until the ShellExecute has finished.

    Does anyone know how to get my code to wait for the shellexecute to finish?

    Thanks in advance!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width