Jump to specific page in matlab multiply times // closing PDF File in Matlab

2 views (last 30 days)
By clicking on a button in a Matlab GUI, the program should jump to a specific page in the PDF using the system command like in this example: system ("Acrobat directory" /A "page=2" "your file directory" &);
But while another Tab is open and the button is clicked on again, it should jump to another page in the same PDF, using the same command, while the pdf file is still open:
System ("Acrobat directory" /A "page=18" "your file directory" &);
But unfortunately Matlab reopens Acrobat Reader at the previous page 2, not at page 18.
When I close Acrobat Reader before calling the system command again, it works. (Closing with: (dos('taskkill /F /IM acroRd32.exe');)
This is an example of how I solved it till now.
function callButton(obj)
switch obj.name
case 'Anna'
cell = 2;
case 'Charlotte'
cell = 18;
dos('taskkill /F /IM acroRd32.exe');
system(['"C:\Program Files (x86)\Adobe\Acrobat Reader DC\Reader\AcroRd32.exe" /A "' ['page=' num2str(cell)] '" "' [path] '" & ']);
Obviously, I don’t want, that Acrobat Reader is always shut down, cause there might be unsaved changes or other needed files still open.
So, is there a way, to close only the specific file in Acrobat Reader, or to even jump to another page without having to close Acrobat before?
I really hope someone can help me :)
  1 Comment
Walter Roberson
Walter Roberson on 27 Aug 2021
Maybe you would be able to get somewhere by using .NET System.Diagnostics.Process to open Acrord32 as a process, as you would then be able to send commands to it. But being able to send commands doesn't necessarily mean that it will respond the commands.
The solution might possibly be to use an ActiveX control to talk to Acrord32

Sign in to comment.

Accepted Answer

Yongjian Feng
Yongjian Feng on 26 Aug 2021
This is not a matlab issue.
If you run those two commands on a terminal, you will see the same behavior. Basically the first command opens Acrobat Reader and jumps to the page. The second command just calls up Acrobat Reader to the front, because it is already opened.
Yongjian Feng
Yongjian Feng on 27 Aug 2021
Might not be possible. It seems like those PDF Open Parameters only allow you to control acrobat/reader when a new instance is started. You might not be able to control an already started instance.

Sign in to comment.

More Answers (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!