1

I would like to subsequently open the same pdf document multiple times on different pages using c# and Adobe Acrobat Reader. The OS is windows.

From this answer I have learned how to evoke a process to start the reader and open a pdf at a desired page or destination. This works fine. However, the only possibility to re-open a pdf document seems to be the option /n which creates a new Acrobat Reader window. Without this option, Acrobat seems to ignore any request to open an already opened file.

Is there any possibility to re-open an already opened pdf at a different page without creating a new tab or window in the reader?

2 Answers2

0

From "Open Parameters for PDF" you can use:

AcroRd32.exe /a "page=1" "D:\Test.pdf"
bad_coder
  • 11,289
  • 20
  • 44
  • 72
ReFran
  • 897
  • 8
  • 14
  • Yes, this opens Test.pdf in the reader on page 1. So how can I subsequently open the same document on page 2 without creating a new reader window using `/n` or without manually closing the reader? Executing `AcroRd32.exe /a "page=2" "D:\Test.pdf"` is simply ignored for me if Test.pdf is already opened. My question is really about **re**-opening files. – thestackexchangeguy Oct 23 '17 at 14:36
0

I think the other options you have are using DDE or FDF. DDE has the disadvantage that Adobe startet some versions ago to change the service name from version to version (actual: "AcroViewR17"). A little bit more work is to use a FDF (special structured text file) with js-code. Not so elegant but reliable since version 4.

Attached you will find the FDF file you need. You have to write and execute it from C#. Change only the filename and js-code stream. The Filename must be OS-independent: Instead of D:\Test.pdf write /D/test.pdf. For testing you can simply save it as test.fdf and execute it via double click.

Good luck, Reinhard

%FDF-1.2 %%---DEMO EXECUTE JAVASCRIPT VIA FDF---%%
1 0 obj << /FDF << /F (/D/Test.pdf)  /JavaScript << /Before 2 0 R  >> >> >> endobj
2 0 obj << >> stream

//my js-code
app.alert(this.numPages); //view total pages
this.pageNum=1;           //goto page number 2 (zero-based)

endstream
endobj
trailer << /Root 1 0 R >> %%EOF
ReFran
  • 897
  • 8
  • 14
  • This works! There are two things which are a bit annoying: 1) I have to click "Allow" in a message box each time when the script is executed. 2) I still get an error message from Acrobat Reader each time I execute this script. The message box simply says "6" without any additional information. However, when I hit OK, the document switches to the desired page. – thestackexchangeguy Oct 24 '17 at 13:54
  • To answer my own comment: 1) Acrobat reader will ask to remember these settings. 2) I figured out that the line `app.alert(this.numPages);` raises a message box. Just comment it out to avoid an error message. – thestackexchangeguy Oct 24 '17 at 14:12
  • Exactly what I would have been answered after solving some problems with my mobil telephony contract. However, by time you may have a look at the Adobe JS-Help file for some other usable code you can use on this way with Reader. – ReFran Oct 24 '17 at 16:34