Skip to main content
Inspiring
January 31, 2022
Question

PDF Reader control (Windows, C#) - How to get current page number?

  • January 31, 2022
  • 2 replies
  • 4824 views

I built a six-panel PDF display app, with 6 instances of the PDF Reader COM control on a Windows Form, and everything works great.

When the program loads, it reads a settings file to open the last set of PDF files so the user can continue where he left off.

 

I use SetCurrentPage so the user can specify what page to start each PDF on. But when the app exits, I need to SAVE the new current page so the user doesn't have to do this manually.

 

In order to restore the last page in each PDF, I have to find out the current page of the PDF Reader controls.

 

The control exposes a .setCurrentPage method, but nothing to GET the current page number. The exposed methods and properties don't seem to provide any access to the current page number.

 

Is there a way to do this?

 

Two DLL's are resident in the project: AxInterop.AcroPDFLib.dll and Interop.AcroPDFLib.dll, if that's relevant.

 

Thanks in advance,

Allen

 

This topic has been closed for replies.

2 replies

Thom Parker
Community Expert
Community Expert
January 31, 2022

Get the AVPageView from the AVDoc, then use AVPageView.GetPage();

 

 

Thom Parker - Software Developer at PDFScriptingUse the Acrobat JavaScript Reference early and often
Inspiring
January 31, 2022

Thanks, Thom,

Is this a COM object? I'm not sure how to include it in the VS IDE for C#.

Also, will there be an instance of AVPageView in every instance of the Reader control?

BTW, this is for internal noncommercial use (and I have a full CC license).

 

I've taken a look at the AVPageView online docs, but I haven't yet seen how to incorporate it into my project.

 

Thom Parker
Community Expert
Community Expert
January 31, 2022

Yes it is a COM object,or rather a COM interface. I may have been mistaken to have suggested it.  This part of the AcroExch API is only available through Acrobat Professional. It's not in Reader 😞  

 

Please see the reference for clarification:

https://opensource.adobe.com/dc-acrobat-sdk-docs/acrobatsdk/html2015/index.html#t=Acro12_MasterBook%2FIAC_DevApp_OLE_Support%2FUsing_OLE.htm

 

 

 

Thom Parker - Software Developer at PDFScriptingUse the Acrobat JavaScript Reference early and often
Bernd Alheit
Community Expert
Community Expert
January 31, 2022

There is no method in the control for this.

Inspiring
January 31, 2022

Ouch. That's a major disappointment. Do you have any suggestions for a slightly more useful way to instantiate a PDF reader inside a Win desktop C# app?

Thanks.