capture save as event

PDF-XChange Viewer SDK for Developer's
(ActiveX and Simple DLL Versions)

Moderators: PDF-XChange Support, Daniel - PDF-XChange, Chris - PDF-XChange, Sean - PDF-XChange, Vasyl - PDF-XChange, Ivan - Tracker Software, Stefan - PDF-XChange

oskpm
User
Posts: 41
Joined: Tue Aug 31, 2010 8:44 am

capture save as event

Post by oskpm »

Hello,

in my project I want to capture the SaveAs-Dialog after a call to place a digital signature.

but only the following events are fired (see attached sample)
Event name Global::FocusGained
Event name Global::FocusGained
Event name Global::BeginModal
Event name Global::FocusGained
Event name Global::EndModal

What I need is the event as mentioned in the help file:
function OnEvent(Type, Name, DataIn, DataOut, Flags)
{
...
if (Type == PXCVA_OnDisplayPrompt)
...
}

Thanks

Regards
Peter
User avatar
Stefan - PDF-XChange
Site Admin
Posts: 19885
Joined: Mon Jan 12, 2009 8:07 am

Re: capture save as event

Post by Stefan - PDF-XChange »

Hello Peter,

Please zip/rar the sample and reupload it as it didn't work the first time.

Best,
Stefan
oskpm
User
Posts: 41
Joined: Tue Aug 31, 2010 8:44 am

Re: capture save as event

Post by oskpm »

now as zip-attachement ...
You do not have the required permissions to view the files attached to this post.
User avatar
Stefan - PDF-XChange
Site Admin
Posts: 19885
Joined: Mon Jan 12, 2009 8:07 am

Re: capture save as event

Post by Stefan - PDF-XChange »

Thanks Peter,

Asked for some advise from the devs and will post here shortly.

Best,
Stefan
mash_inc
User
Posts: 37
Joined: Tue Jan 25, 2011 3:11 pm

Re: capture save as event

Post by mash_inc »

Hello Peter,

as a C# developer an newbie to PDFXchange I also was a little bit confused about the event handling.
The first thing is that the signature of the event handler method is not as described in the help file.

Code: Select all

void viewer_OnEvent(object sender, AxPDFXCviewAxLib._IPDFXCviewEvents_OnEventEvent e) {
Nevertheless, maybe my example will help you.

I want to show a special messagebox when a document gets save.
Therefore in need to now when the BeforeSaveDoc event is fired.
When the user does not want to save, I need to set the Cancel flag of the BeforeSaveDoc event.

Here is how I do that:

Code: Select all

void viewer_OnEvent(object sender, AxPDFXCviewAxLib._IPDFXCviewEvents_OnEventEvent e) {
  var viewer = sender as AxPDFXCviewAxLib.AxCoPDFXCview;

  if (e.name == "Notifications.BeforeSaveDoc") {
    if (MessageBox.Show("Realy want to save?", "Question", MessageBoxButtons.YesNo) == System.Windows.Forms.DialogResult.No) {
      viewer.SetProperty("Notifications.BeforeSaveDoc.Cancel", 1);
    }
  }
}
As you can see, you need to use the SetProperty (or GetProperty) of the corresponding viewer control to read or set settings of the "pseudo" event.
If there is a smarter way to do that, please let me know.

Kind regards,

Tino
User avatar
Stefan - PDF-XChange
Site Admin
Posts: 19885
Joined: Mon Jan 12, 2009 8:07 am

Re: capture save as event

Post by Stefan - PDF-XChange »

Many thanks for the help Tino,

Much appreciated.

All we need is now for Peter to confirm it also works for him :)

Cheers,
Stefan
oskpm
User
Posts: 41
Joined: Tue Aug 31, 2010 8:44 am

Re: capture save as event

Post by oskpm »

mash_inc wrote:Hello Peter,

as a C# developer an newbie to PDFXchange I also was a little bit confused about the event handling.
The first thing is that the signature of the event handler method is not as described in the help file.

Code: Select all

void viewer_OnEvent(object sender, AxPDFXCviewAxLib._IPDFXCviewEvents_OnEventEvent e) {
Thanks for help. I think every C# event uses this signature: void EventFunc(object sender, object param2)
Unforunately this won't help in VC++, as event handling is different. Perhaps there is also a 2nd undocumented func-sig for VC++ and the ActiveX-Component?

Regards,
Peter
User avatar
Stefan - PDF-XChange
Site Admin
Posts: 19885
Joined: Mon Jan 12, 2009 8:07 am

Re: capture save as event

Post by Stefan - PDF-XChange »

Hi Peter,

I have asked for some help from the guys that are more into it with VC++ and we should get a response here shortly.

Best,
Stefan
User avatar
Vasyl - PDF-XChange
Site Admin
Posts: 2445
Joined: Thu Jun 30, 2005 4:11 pm

Re: capture save as event

Post by Vasyl - PDF-XChange »

Hi, Peter
I think every C# event uses this signature: void EventFunc(object sender, object param2)
Unforunately this won't help in VC++, as event handling is different. Perhaps there is also a 2nd undocumented func-sig for VC++ and the ActiveX-Component?
Please look to our VC++ examples for PDF-XChange Viewer ActiveX SDK (for example <InstalledSDK>\Examples\CExamples\FullDemo\MainDlg.h/MainDlg.cpp). The C++ signature for event handler:

Code: Select all

HRESULT __stdcall OnEvent(/*[in]*/ LONG Type, /*[in]*/ BSTR Name, /*[in]*/ VARIANT DataIn, /*[out]*/ VARIANT* DataOut, /*[in]*/ LONG Flags);
HTH.
PDF-XChange Co. LTD (Project Developer)

Please archive any files posted to a ZIP, 7z or RAR file or they will be removed and not posted.
oskpm
User
Posts: 41
Joined: Tue Aug 31, 2010 8:44 am

Re: capture save as event

Post by oskpm »

Vasyl-Tracker Dev Team wrote:Hi, Peter
Please look to our VC++ examples for PDF-XChange Viewer ActiveX SDK (for example <InstalledSDK>\Examples\CExamples\FullDemo\MainDlg.h/MainDlg.cpp). The C++ signature for event handler:

Code: Select all

HRESULT __stdcall OnEvent(/*[in]*/ LONG Type, /*[in]*/ BSTR Name, /*[in]*/ VARIANT DataIn, /*[out]*/ VARIANT* DataOut, /*[in]*/ LONG Flags);
HTH.
Yes, this is exactly my event handler. Please look at my sample code to reproduce the behaviour.

Regards,
Peter
User avatar
Vasyl - PDF-XChange
Site Admin
Posts: 2445
Joined: Thu Jun 30, 2005 4:11 pm

Re: capture save as event

Post by Vasyl - PDF-XChange »

Hi Peter.

Please look to the attached file. Thanks to Tino for good solution :).

NOTE: currently you can sign the documents which already contains the unsigned(!) form fields with special type "Digital Signature", so, if document doesn't contain it then this ExecuteCommand won't work. In the new version (V3) you will be able to detect this case and add unsigned dig-sign. form field before signing..

Best
Regards.
You do not have the required permissions to view the files attached to this post.
PDF-XChange Co. LTD (Project Developer)

Please archive any files posted to a ZIP, 7z or RAR file or they will be removed and not posted.
oskpm
User
Posts: 41
Joined: Tue Aug 31, 2010 8:44 am

Re: capture save as event

Post by oskpm »

Hi all,

thanks for sample code, but I think we talk past each other :wink:
My problem is, that the event is simply not fired. Tested with Visual Studio 6 MFC and Visual Studio 2010 MFC, both with the ActiveX-Control.

See output of afxDump. The string 'Notifications.BeforeSaveDoc' is not in debug output.

Code: Select all

void CPDFXEventDlg::OnOnEventCopdfxcview(long Type, LPCTSTR Name, const VARIANT FAR& DataIn, VARIANT FAR* DataOut, long Flags) 
{
	afxDump << "Event name " << Name << "\n";

	if (bDigSigning)
	{
		if ((Type == PXCVA_OnNamedNotify) && (lstrcmpi(Name, _T("Notifications.BeforeSaveDoc")) == 0))
		{
			AfxMessageBox("this code will never be executed ...");
//...
Regards,
Peter
User avatar
Vasyl - PDF-XChange
Site Admin
Posts: 2445
Joined: Thu Jun 30, 2005 4:11 pm

Re: capture save as event

Post by Vasyl - PDF-XChange »

Hi, Peter.

What version of SDK is used by you? Should be 2.5.191 because it is new notify...

HTH
PDF-XChange Co. LTD (Project Developer)

Please archive any files posted to a ZIP, 7z or RAR file or they will be removed and not posted.
oskpm
User
Posts: 41
Joined: Tue Aug 31, 2010 8:44 am

Re: capture save as event

Post by oskpm »

Hi Vasyl
Vasyl-Tracker Dev Team wrote:Hi, Peter.

What version of SDK is used by you? Should be 2.5.191 because it is new notify...
HTH
Installed version was 2.5.0190.
Now updated to current version 2.5.191 and problem seems to be solved.

Thanks a lot to all.

Regards
Peter
User avatar
Stefan - PDF-XChange
Site Admin
Posts: 19885
Joined: Mon Jan 12, 2009 8:07 am

Re: capture save as event

Post by Stefan - PDF-XChange »

:)