0

I am trying to open the pdf at the nameddest-- The bookmark I created using Adobe Acrobat Pro. I tried with the pagenumber, the same code but page instead of nameddest. It works just fine (Abode Acrobat Reader opens the pdf at specific page). However, it doesn't work with nameddest. It just opens the first page. I was wondering if the parameter.format() is the correct formatting to pass on ShellExecute?? Would appreciate if someone has any idea. If not, any better alternative ideas I can try instead of ShellExecute()??

    CString readerPath = "\"" + path + "\""; // path for PDF to read
    CString szNamedest = "Help";
    CString parameter;
    parameter.Format("/n /A \"nameddest=%s\" %s", szNamedest, readerPath);
   //parameter.Format("/n /A \"page=27\" %s", readerPath); //this works just fine
//acrobatpath is the path for acrord32.exe 
    ShellExecute(NULL, "open", acrobatpath, parameter, NULL, SW_SHOWNORMAL);
the_asura
  • 21
  • 3
  • As I already mentioned in [my answer](https://stackoverflow.com/a/72551737/65863) to your [previous question](https://stackoverflow.com/questions/72550984/), you should be using `CreateProcess()` to run an `.exe` file directly, not `ShellExecute()`. But more importantly, in your `Format()` call, you are specifying the file path of the reader's `.exe` file where you need to specify the `.pdf` file instead. You are asking the reader to open itself. – Remy Lebeau Jun 16 '22 at 17:04
  • @RemyLebeau I appreciate it. Pagenumber was working fine so thought named destination would work too. thanks for the direction. Is there any right documentation or reference for CreateProcess(). Kind of newbie here so would really appreciate. Already drained out... – the_asura Jun 16 '22 at 17:09
  • "*Pagenumber was working fine*" - not if you were specifying the `.exe` file path instead of the `.pdf` file path. "*so thought named destination would work too*" - it should, if you fix your parameter format. You should not be passing `readerPath` to `parameter.Format()`. Also, why are you using the `/n` parameter? "*Is there any right documentation or reference for CreateProcess()*" - https://learn.microsoft.com/en-us/windows/win32/api/processthreadsapi/nf-processthreadsapi-createprocessa – Remy Lebeau Jun 16 '22 at 17:09
  • My bad! "you are specifying the file path of the reader's .exe file where you need to specify the .pdf file instead". --it is .pdf file path. I corrected the comment. – the_asura Jun 16 '22 at 17:26
  • @KJ you right. That's why I tried keeping just a word. file:///C:/Users/asura/Downloads/Test.pdf#nameddest=Help , just works fine in Edge and Chrome. Idk what I am missing here in parameter formatting. It doesn't work in Acrobat, which is the goal. – the_asura Jun 16 '22 at 17:29

0 Answers0