0

I want to move to a page in a pdf file in c++. I use shellExecute and it works fine. But if the file has been opened before, it will not go to destination page. I want to check if the file is open and close it before using shellExecute command. How can I do it and is there any better way?

maryamT
  • 23
  • 8
  • 4
    I fail to see the C++ question here. For that matter I fail to see a shell question here. It might be related to PDF. Most probably this depends strongly on the particular PDF reader you're using. There are many. – Cheers and hth. - Alf Jun 16 '15 at 09:37
  • what do you want to do with the PDF? Do you only want to check if the PDF is open? Or do you want to manipulate the PDF? – CML Jun 16 '15 at 10:18
  • @ CML: just check if it is open – maryamT Jun 16 '15 at 10:49

2 Answers2

0

You can use

is_open()

to check if a file is opened or not. I think you have to include iostream and/or fstream. Not sure..

Maybe this question will help you: Question

CML
  • 353
  • 7
  • 18
0

Use these lines of code

std::ifstream ifs ("test.pdf");

if (ifs.is_open()) {
  ifs.close();
}
shihab mm
  • 505
  • 5
  • 15