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?
Asked
Active
Viewed 525 times
0
-
4I 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 Answers
0
Use these lines of code
std::ifstream ifs ("test.pdf");
if (ifs.is_open()) {
ifs.close();
}

shihab mm
- 505
- 5
- 15
-
-
`std::ifstream ifs ("test.pdf");` will automatically open the file we specified as parameter. – shihab mm Jun 16 '15 at 10:55
-
-
I think file stream will give some error if we are trying to open already opened file. you can catch it by adding try catch block. – shihab mm Jun 16 '15 at 11:27
-