-
September 9th, 2021, 10:39 AM
#1
Control PDF from c ++
I wanted to put the PDF file on one page. When opening with "# page = 123" or "/ A page = 123" in the path or as a parameter in ShellExecute does not work.
How could you do that when PDF is already open?
I couldn't find the list of parameters. It would be nice to know how to ship them too.
Thanks for the answers
-
September 9th, 2021, 12:34 PM
#2
Re: Control PDF from c ++
Victor Nijegorodov
-
September 9th, 2021, 05:20 PM
#3
Re: Control PDF from c ++
Thanks ViktorN for the parameter list.
I had the idea that it could be done from c / ++ for example. with ShellExecute (NULL / GetDesktopWindow (), "open", "Path \ File", p1, NULL, SW_NORMAL)
Open works when p1 = NULL.
With p1 = "# page = 3" or "/ A page = 3" does not work.
Is there a way to design the parameter p1 so that ShellExecute (or CreateProcess) opens the file and places it on a page?
And it remains to put open PDF on one page. Is it possible without a PDF library with Send / PostMessages?
-
September 10th, 2021, 01:27 AM
#4
Re: Control PDF from c ++
Originally Posted by danekbb
...
With p1 = "# page = 3" or "/ A page = 3" does not work.
...
did you try to pass parameters without paces? Like
Last edited by VictorN; September 10th, 2021 at 02:22 AM.
Victor Nijegorodov
-
September 10th, 2021, 02:59 AM
#5
Re: Control PDF from c ++
Originally Posted by danekbb
I wanted to put the PDF file on one page. When opening with "# page = 123" or "/ A page = 123" in the path or as a parameter in ShellExecute does not work.
How could you do that when PDF is already open?
...
I guess you would need some kind of PDF SDK to proper implement it.
See https://www.pdftron.com/documentatio...ation/windows/
and/or some other suggestions of Google:
https://www.google.com/search?q=pdf+...4dUDCA4&uact=5
Victor Nijegorodov
-
September 10th, 2021, 04:51 AM
#6
Re: Control PDF from c ++
If man
ShellExecute (NULL / GetDesktopWindow (), "open", "Path \ File", p1, NULL, SW_NORMAL)
calls, where p1 = "#page=3", "/A page=3", "/ A "page=3""
PDF file be opened, but not set on page (3).
The previous examples did not provide a solution
-
September 10th, 2021, 05:19 AM
#7
Re: Control PDF from c ++
Originally Posted by danekbb
ShellExecute (NULL / GetDesktopWindow (), "open", "Path \ File", p1, NULL, SW_NORMAL)
This line does not compile!
Originally Posted by danekbb
... where p1 = "#page=3", "/A page=3", "/ A "page=3""
PDF file be opened, but not set on page (3).
Try
Victor Nijegorodov
-
September 10th, 2021, 07:06 AM
#8
Re: Control PDF from c ++
I have already tried this parameter without success.
I don't like integrating a library: it's nice that others know how to do it, but I want to know myself.
-
September 10th, 2021, 07:47 AM
#9
Re: Control PDF from c ++
This code works for me opening the page 2:
Code:
HINSTANCE result = ::ShellExecute(nullptr, _T("open"), _T("AcroRd32.exe"), _T("/A page=2 D:\\Development\\myPath\\myFile.pdf"), nullptr, SW_SHOWNORMAL);
Victor Nijegorodov
-
September 10th, 2021, 10:32 AM
#10
Re: Control PDF from c ++
Wow. Open the PDF file with
HINSTANCE result = :: ShellExecute (nullptr, _T ("open"), _T ("AcroRd32.exe"), _T ("/ A page = 2 D: \\ Development \\ myPath \\ myFile.pdf"), nullptr , SW_SHOWNORMAL);
functions.
Thanks VictorN.
The thing would really be complete if you could navigate to a page of an open PDF.
Does anyone know ?
-
September 10th, 2021, 10:50 AM
#11
Re: Control PDF from c ++
Originally Posted by danekbb
...
The thing would really be complete if you could navigate to a page of an open PDF.
Does anyone know ?
I still guess you would have to use some kind on PDF SDK to accomplish it.
Just the same way as to work with opened MS Word or MS Excel file one have to use the corresponding Word or Excel Automation.
Victor Nijegorodov
-
September 12th, 2021, 09:13 AM
#12
Re: Control PDF from c ++
It is possible that it is difficult to navigate to a page in an open PDF without a PDF SDK. However, the solution to navigate to the page when it is opened is not bad.
Unfortunately, that only takes care of part of the problem.
Because if the PDF file is in the directory "c: \ program files \ doc", AcroRd32.exe can not find it. Error message: it is the directory syntax, and it affects every directory whose name contains a space.
Occasionally I had problems with it that could be fixed with quotation marks.
In that case it is not so.
Does anyone know the correct syntax for AcroRd32.exe with the space in the name of a directory ?
-
September 12th, 2021, 12:51 PM
#13
Re: Control PDF from c ++
I looked for something, tried it and solved the problem.
The correct syntax is:
ShellExecute (NULL, _T ("open"), _T ("AcroRd32.exe"), _T ("/ A \” page = 2 ”\” Pathfile.pdf \ ”"), NULL, SW_SHOW);
I.e. parameters and PathFile.PDF must have quotation marks
-
September 12th, 2021, 02:42 PM
#14
Re: Control PDF from c ++
Originally Posted by danekbb
I looked for something, tried it and solved the problem.
The correct syntax is:
ShellExecute (NULL, _T ("open"), _T ("AcroRd32.exe"), _T ("/ A \” page = 2 ”\” Pathfile.pdf \ ”"), NULL, SW_SHOW);
I.e. parameters and PathFile.PDF must have quotation marks
Yes! Any parameter containing the space must be within the quotation marks.
And it is valid not only for AcroRd32.exe.
Victor Nijegorodov
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|