Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. How to ShellExecute a PDF to a specific page

How to ShellExecute a PDF to a specific page

Scheduled Pinned Locked Moved C / C++ / MFC
adobetutorialquestion
5 Posts 5 Posters 2 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • D Offline
    D Offline
    DanYELL
    wrote on last edited by
    #1

    I have a PDF. If I use this CString Path = GetPath("manual.pdf"); ShellExecute(0, "open", Path, NULL, NULL, SW_SHOWNORMAL); The PDF executes. But if I then use Path += "#page=17"; ShellExecute(0, "open", Path, NULL, NULL, SW_SHOWNORMAL); or anything similar, I cant get the PDF to execute. I want the PDF to execute and jump to a specific page. I found solutions, I think, where I can execute the adobe.exe file and the path, but I dont know where adobe.exe is located on these computers. Is there any way to execute a PDF without knowing where the adobe executable is at? Please, any response any one can give me will be greatly appreciated.

    enhzflepE L G D 4 Replies Last reply
    0
    • D DanYELL

      I have a PDF. If I use this CString Path = GetPath("manual.pdf"); ShellExecute(0, "open", Path, NULL, NULL, SW_SHOWNORMAL); The PDF executes. But if I then use Path += "#page=17"; ShellExecute(0, "open", Path, NULL, NULL, SW_SHOWNORMAL); or anything similar, I cant get the PDF to execute. I want the PDF to execute and jump to a specific page. I found solutions, I think, where I can execute the adobe.exe file and the path, but I dont know where adobe.exe is located on these computers. Is there any way to execute a PDF without knowing where the adobe executable is at? Please, any response any one can give me will be greatly appreciated.

      enhzflepE Offline
      enhzflepE Offline
      enhzflep
      wrote on last edited by
      #2

      I suspect you can't open it to a specific page without knowing where Acrobat resides, but no matter - you can find that out from the registry apparently. If you have a look at the key: HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\AcroRd32.exe\ you can get the full-path of the exe. From there, it's seems to be just a matter of passing that file to shell execute along with using a parameter that includes (1) the full path to the pdf doc and (2) the desired page num. Anyhoo - here's my source: http://www.devhut.net/2013/12/04/vba-open-a-pdf-to-a-specific-page/[^]

      1 Reply Last reply
      0
      • D DanYELL

        I have a PDF. If I use this CString Path = GetPath("manual.pdf"); ShellExecute(0, "open", Path, NULL, NULL, SW_SHOWNORMAL); The PDF executes. But if I then use Path += "#page=17"; ShellExecute(0, "open", Path, NULL, NULL, SW_SHOWNORMAL); or anything similar, I cant get the PDF to execute. I want the PDF to execute and jump to a specific page. I found solutions, I think, where I can execute the adobe.exe file and the path, but I dont know where adobe.exe is located on these computers. Is there any way to execute a PDF without knowing where the adobe executable is at? Please, any response any one can give me will be greatly appreciated.

        L Offline
        L Offline
        Lost User
        wrote on last edited by
        #3

        The third parameter in the call to ShellExecute[^] can be used to pass the extra parameters to the called application. All you need to do is check Adobe reader for the format of those parameters.

        1 Reply Last reply
        0
        • D DanYELL

          I have a PDF. If I use this CString Path = GetPath("manual.pdf"); ShellExecute(0, "open", Path, NULL, NULL, SW_SHOWNORMAL); The PDF executes. But if I then use Path += "#page=17"; ShellExecute(0, "open", Path, NULL, NULL, SW_SHOWNORMAL); or anything similar, I cant get the PDF to execute. I want the PDF to execute and jump to a specific page. I found solutions, I think, where I can execute the adobe.exe file and the path, but I dont know where adobe.exe is located on these computers. Is there any way to execute a PDF without knowing where the adobe executable is at? Please, any response any one can give me will be greatly appreciated.

          G Offline
          G Offline
          Graham Breach
          wrote on last edited by
          #4

          Another thing to think about is whether the computers you are targetting have Adobe reader installed at all. Personally, I use SumatraPDF for viewing PDFs, but there is a Microsoft reader app (its name escapes me right now), Foxit Reader, and probably others. Each of them could have different ways to specify the page to show first.

          1 Reply Last reply
          0
          • D DanYELL

            I have a PDF. If I use this CString Path = GetPath("manual.pdf"); ShellExecute(0, "open", Path, NULL, NULL, SW_SHOWNORMAL); The PDF executes. But if I then use Path += "#page=17"; ShellExecute(0, "open", Path, NULL, NULL, SW_SHOWNORMAL); or anything similar, I cant get the PDF to execute. I want the PDF to execute and jump to a specific page. I found solutions, I think, where I can execute the adobe.exe file and the path, but I dont know where adobe.exe is located on these computers. Is there any way to execute a PDF without knowing where the adobe executable is at? Please, any response any one can give me will be greatly appreciated.

            D Offline
            D Offline
            David Crow
            wrote on last edited by
            #5

            What is the net value of Path?

            "One man's wage rise is another man's price increase." - Harold Wilson

            "Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons

            "You can easily judge the character of a man by how he treats those who can do nothing for him." - James D. Miles

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups