I am trying to open a .pdf
at a specific named destination using ShellExecute()
, but I couldn't figure out how the parameters should be formatted. The paramater I am using here is pagew
.
Has anyone tried this before? I found a couple of answers, but they were not helpful as I need.
PS: opening just the .pdf
works fine.
int main()
{
std::string url = "\"C:/Users/asura/Downloads/asuras.pdf\"";
std::wstring stemp = std::wstring(url.begin(), url.end());
LPCWSTR sw = stemp.c_str();
std::string action = "open";
std::wstring atemp = std::wstring(action.begin(), action.end());
LPCWSTR actiont = atemp.c_str();
//1 INTRODUCTION
string strPageDestination = "/A \"page=52\" \"pdf\"";
std::wstring pagetemp = std::wstring(strPageDestination.begin(), strPageDestination.end());
LPCWSTR pagew = pagetemp.c_str();
//The line below works fine, it opens pdf with default pdf opener at first page.
//ShellExecute(NULL, actiont, sw, NULL, NULL, SW_SHOWNORMAL);
//The line below attempting to open file at specific page number doesn't work
ShellExecute(NULL, actiont, sw, pagew, NULL, SW_SHOWNORMAL);
return 0;
}
CodePudding user response:
In comments, you state:
I am using Adobe Acrobat Reader DC as default viewer.
Acrobat can be a lot fussier about the syntax when called direct you place the /Action before the file name
"C:\SandBox\apps\PDF\Adobe\Reader\AcroRd32.exe" /A page=52 "C:\Users\asura\Downloads\asuras.pdf"