In comments, you state:
I am using Adobe Acrobat Reader DC as default viewer.
According to this Acrobat documentation (and others like it that I found):
You can open a PDF document with a command or URL that specifies exactly what to display (a named destination or specific page), and how to display it (using such characteristics as a specific view, scrollbars, bookmarks, annotations, or highlighting).
The parameters for URLs are supported by most browsers, and can be used when opening PDF documents programmatically.
Many of these parameters can be passed to the following core API functions (see the Acrobat and PDF Library API Reference for details):
AVDocOpenFromFileWithParamString
AVDocOpenFromASFileWithParamString
AVDocOpenFromPDDocWithParamString
When opening a PDF document from a command shell, you can pass the parameters to the open command using the /A
switch with the following syntax:
<Acrobat path> /A "<parameter>=<value>" "<PDF path>"
For example:
Acrobat.exe /A "zoom=1000" "C:\example.pdf"
In Mac OS, you can use the parameters when opening a PDF document with an Apple event.
I have Adobe Acrobat Reader DC installed, and from looking at the way it is registered in the Windows Registry, using ShellExecute("open")
with just a .pdf
file path WILL NOT be able to produce the command syntax outlined above that Acrobat requires when using the /A
parameter. It doesn't matter what you pass in to the lpParameters
parameter of ShellExecute()
, it will be ignored by Acrobat.
So, the way I see it, you have two choices:
run the Acrobat .exe
program directly by using CreateProcess()
, specifying the complete command-line you need.
use ShellExecute()
to launch a web browser specifying a URL to the .pdf
file, in the format outlined in the Acrobat documentation, as follows:
You can specify multiple parameters in a single URL. Separate each parameter with either an ampersand (&) or a pound (#) character. Actions are processed and executed from left to right as they appear in the URL.
Because all specified actions are executed, it is possible that later actions will override the effects of previous actions, so it is important to use the correct order. For example, page actions should appear before zoom actions.
Commands are not case sensitive except for the value of a named destination. There can be no spaces in the URL.
URL examples
...
http://example.org/doc.pdf#page=3
...
I have not tried using a URL, but this approach may require you to run a local HTTP server, or at least use a file:
url, in order to open a local .pdf
file via a URL.