Events in the PDF Viewer Component

PDF Viewer Component Events

1. Ready to Open Document Event
Event: HRESULT NotifyCtrlReady();
Description: Ready to open document.
When the component finished the initialization the NotifyCtrlReady event is raised. The event allows you to open a new document after the component has released all the resources are ready to open a new document.
HTML + JScript
<html>
<script language=javascript id=clientEventHandlersJS>
function NotifyCtrlReadyEvent ()
{
PDFViewer1.Open “http://www.ocxt.com/demo/sample.pdf”
}
</script>

<body>
<object classid=”clsid: 44A8091F-8F01-43B7-8CF7-4BBA71E61E04 ” id=”PDFViewer1″ width=”657″ height=”452″>
<param name=”Toolbars” value=”0″>
</object>
</body>

<script language=”JScript” for=PDFViewer1 event=” NotifyCtrlReady ()”>
NotifyCtrlReadyEvent ();
</script>
</html>

2. Document Opened Event
Event: void OnDocumentOpened([in] BSTR FileName);
Description: Called when document is opened or new document added.
Every time a user opened a file successfully, the OnDocumentOpened event is raised. The event allows you to override the default behavior for the control and supply your own custom actions and dialog boxes to do normal file operations.
HTML + JScript
<script language=”JScript” for=PDFViewer1 event=” OnDocumentOpened(FileName)”>
OnDocumentOpenedEvent(FileName);
</script>
<script language=javascript>
function OnDocumentOpenedEvent(FileName)
{
Alert(“Respond the Document Opened Event.”);
}
</script>

3. Document Close Event
Event: void OnDocumentClosed();
Description: Called when document is closed.
Every time a user closed a file successfully, the OnDocumentClosed event is raised. The event allows you to override the default behavior for the control and supply your own custom actions and dialog boxes to do normal file operations.
HTML + JScript
<script language=”JScript” for= PDFViewer1 event=” OnDocumentClosed()”>
OnDocumentClosedEvent();
</script>
<script language=javascript>
function OnDocumentClosedEvent()
{
Alert(“Respond the Document Close Event.”);
}
</script>

4. Before Document Closed Event
Event: void BeforeDocumentClosed( [in,out] VARIANT* Cancel);
Description: Called before document is closed (may be canceled).
Every time before a user closed a document the OnActivationChange event is raised. The event allows you to override the default behavior for the control and supply your own custom actions and dialog boxes to do normal file operations.
HTML + JScript
<script language=”JScript” for= PDFViewer1 event=” BeforeDocumentClosed (Cancel)”>
OnBeforeDocumentClosedEvent(GoingActive);
</script>
<script language=javascript>
function OnBeforeDocumentClosedEvent (GoingActive)
{
Alert(“Respond the Before Document Closed Event.”);
}
</script>

5. Before Document Saved Event
Event: void BeforeDocumentSaved( [in,out] VARIANT* Cancel);
Description: Called before document is saved (may be canceled).
Every time a user opens a new document or closes a document the OnActivationChange event is raised. The event allows you to override the default behavior for the control and supply your own custom actions and dialog boxes to do normal file operations.
HTML + JScript
<script language=”JScript” for= PDFViewer1 event=” BeforeDocumentSaved( Cancel)”>
OnBeforeDocumentSavedEvent(GoingActive);
</script>

<script language=javascript>
function OnBeforeDocumentSavedEvent ( Cancel)
{
Alert(“Respond the Before Document Saved Event.”);
}
</script>

6. Before Right Click the Window
Event: HRESULT OnWindowBeforeRightClick();
Description: Called before right click the component. The event needs the DisableViewRightClickMenu method or DisableToolbarRightClickMenu method is called.

7. Before Double Click the Window
Event: HRESULT OnWindowBeforeDoubleClick ();
Description: Called before double click the component.

8. Before Download File
Event: HRESULT BeforeDownloadFile ();
Description: Called before downloading the file.

9. Download File Completed
Event: HRESULT DownloadFileComplete ();
Description: Called when the file was downloaded completely.

PDF Viewer Component – Disables the Hot Keys such as Save, Copy, Print.

Enable the developers to disables the Hot Keys such as Save, Copy, Print in the PDF Viewer Component.
Function: void DisableHotKeyPrint();
  void DisableHotKeySave();
  void DisableHotKeyCopy();
  void DisableHotKeyShowBookMarks();
  void DisableHotKeyShowThumnails();
  void DisableHotKeyShowToolbars();
  void DisableHotKeySearch();
Description: Disables the hotkeys at the Adobe Reader.

PDF Viewer Component – Disable File Toolbar

Function: boolean DisableFileToolbar (boolean bDisable);
Description: Disables the File toolbars. The method must be call after the PDF file opened.

PDF Viewer Component – Disable View Right Click Menu

Function: boolean DisableViewRightClickMenu (boolean bDisable);
Description: Disables the right click menu at the view. The method must be call after the PDF file opened.

PDF Viewer Component – Disable the Toolbar Right Click

Function: boolean DisableToolbarRightClickMenu(boolean bDisable);
Description: Disables the right click menu at the toolbars. The method must be call after the PDF file opened.

PDF Viewer Component – Disable Toolbars in the Adobe Reader

Function: boolean DisableToolbar(boolean bDisable)
Description: Disables all the toolbars in the Adobe Reader. The method must be call after the PDF file opened.

Tips:
 If you want to disable the toobars when you load a pdf file, you need put the method at OnDocumentOpened event.
 <SCRIPT ID=clientEventHandlersJS LANGUAGE=javascript>
 function PDFViewer1_NotifyCtrlReady()
 {
        document.PDFViewer1.LoadFile (“e:\\OA_Reference2.pdf”);
 }
 function PDFViewer1_OnDocumentOpened(FileName)
 {
        document.PDFViewer1.DisableToolbar (true);
 }
 </SCRIPT>
 <SCRIPT LANGUAGE=javascript FOR=PDFViewer1 EVENT=NotifyCtrlReady>
 <!–
 PDFViewer1_NotifyCtrlReady();
 //–>
 </SCRIPT>
 <SCRIPT LANGUAGE=javascript FOR=PDFViewer1 EVENT=OnDocumentOpened(FileName)>
 <!–
 PDFViewer1_OnDocumentOpened(FileName);
 //–>
 </SCRIPT>

PDF Viewer Component – Load PDF File ReadOnly

Load PDF File
Function void LoadFile (BSTR strPath);
Description: Opens a PDF file located on a drive or remote web server.

PDFViewer1. LoadFile “http://www.ocxt.com/demo/samples/pdfviewerref.pdf”
Or PDViewer1.LoadFile ”c:\test.pdf”

Whether was the Adobe Reader Installed

You can use the component to return whether the Adobe Reader was Installed.
Function: boolean AdobeReaderIsInstalled ();
Description: Returns whether the client installs the PDF Reader.

How to get the adobe reader version number

Get Adobe Reader Version
Function: BSTR GetVersions ();
Description: Returns the version number of the Adobe PDF Reader.

PDF Viewer Component – Page Navigation

Go to the First Page
Function: boolean GotoFirstPage ();
Description: Goes to first page of the PDF document.

Go to the Previous Page
Function: boolean GotoPreviousPage ();
Description: Goes to previous page of the PDF document.

Go to the Next Page
Function: boolean GotoNextPage();
Description: Goes to next page of the PDF document.

Go to the last Page
Function: boolean GotoLastPage();
Description: Goes to last page of the PDF document.