Changing Identity.Name no longer working?

PDF-XChange Editor SDK for Developers

Moderators: TrackerSupp-Daniel, Tracker Support, Paul - Tracker Supp, Vasyl-Tracker Dev Team, Chris - Tracker Supp, Sean - Tracker, Ivan - Tracker Software, Tracker Supp-Stefan

Forum rules
DO NOT post your license/serial key, or your activation code - these forums, and all posts within, are public and we will be forced to immediately deactivate your license.

When experiencing some errors, use the IAUX_Inst::FormatHRESULT method to see their description and include it in your post along with the error code.
Post Reply
JGForwick
User
Posts: 16
Joined: Fri Jan 21, 2011 7:17 pm

Changing Identity.Name no longer working?

Post by JGForwick »

I am trying to set the Identity.Name to a custom value so that any new stamps or annotations added to a document will display the custom name as the author. Searching the forums it seems that

viewtopic.php?f=66&t=25765&p=100727&hil ... me#p100783 recommends using...

Code: Select all

pdfCtl.Inst.Settings["Identity.Name"].v = "My Identity Name";
pdfCtl.Inst.FireAppPrefsChanged(PDFXEdit.PXV_AppPrefsChanges.PXV_AppPrefsChange_Identity);
...as the solution. However using your FullDemo sample solution this does not seem to work.

As an example I have edited the open btnOpen_Click() event in the sample to include the above code at the start, but no matter what when I add a stamp or annotation, the author name is still my windows user name, NOT the custom Identity.Name set above.

Is this a bug? This is using the current Editor SDK downloaded a few days ago.
Sasha - Tracker Dev Team
User
Posts: 5522
Joined: Fri Nov 21, 2014 8:27 am
Contact:

Re: Changing Identity.Name no longer working?

Post by Sasha - Tracker Dev Team »

Hello JGForwick,

Here's a code snippet that should work for your case:

Code: Select all

			if (e.nEventID == nIDS[(int)IDS.e_annots_inserted])
			{
				PDFXEdit.IPXV_Document Doc = (PDFXEdit.IPXV_Document)e.pFrom;
				IntPtr outPtr;
				Doc.ActiveView.Obj.QueryImpl(typeof(PDFXEdit.IUIX_ObjImpl).GUID, null, out outPtr);
				PDFXEdit.IUIX_ObjImpl uiObjImpl = (PDFXEdit.IUIX_ObjImpl)System.Runtime.InteropServices.Marshal.GetObjectForIUnknown(outPtr);
				PDFXEdit.IUIX_Obj obj = uiObjImpl.Obj;
				PDFXEdit.IPXV_AnnotsEvent ae = (PDFXEdit.IPXV_AnnotsEvent)e.pEvent;
				PDFXEdit.IPXV_AnnotsList AL = ae.Items;

				PDFXEdit.IPXS_Inst pSInt = (PDFXEdit.IPXS_Inst)pdfCtl.Inst.GetExtension("PXS");
				int nID = pdfCtl.Inst.Str2ID("op.annots.setProps", false);
				PDFXEdit.IOperation Op = pdfCtl.Inst.CreateOp(nID);
				PDFXEdit.ICabNode input = Op.Params.Root["Input"];
				for (uint i = 0; i < AL.Count; i++)
				{
					PDFXEdit.IPXC_Annotation annot = AL[i];
					input.Add().v = annot;
				}
				if (input.Count == 0)
					return;
				PDFXEdit.ICabNode options = Op.Params.Root["Options"];
				options["Subject"].v = "Test Subject";
				options["Author"].v = "Test Author";
				options["Mask"].v = PXV_OpModifyAnnotMaskFlags.OpModifyAnnot_Author | PXV_OpModifyAnnotMaskFlags.OpModifyAnnot_Subject;
				Op.Do();


			}
The event itself should be handled in the pdfCtl_OnEvent method. Do not forget to add the event to the IDS for handling it.
Cheers,
Alex
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
JGForwick
User
Posts: 16
Joined: Fri Jan 21, 2011 7:17 pm

Re: Changing Identity.Name no longer working?

Post by JGForwick »

Hi Sasha,

Thanks for the reply. This seems to work in the sample app, thanks. The eventId for e_annots_inserted is 3251 correct? These Ids arent somehow dynamic are they? When I trap for the same Id in our app, that Id never seems to come up when I am adding annotations.

edit: upon further review it appears that the OnEvent event is not being triggered by the control in our application. In the following code all debug statements will be logged during the appropriate action (resizing, focusing, leaving focus etc) *except* the OnEvent debug statement.

Code: Select all

        private void pdfXChangeEditor_Resize(object sender, EventArgs e)
        {
            Debug.WriteLine("pdfXChangeEditor_Resize");
        }

        private void pdfXChangeEditor_VisibleChanged(object sender, EventArgs e)
        {
            Debug.WriteLine("pdfXChangeEditor_VisibleChanged");
        }

        private void pdfXChangeEditor_Enter(object sender, EventArgs e)
        {
            Debug.WriteLine("pdfXChangeEditor_Enter");
        }

        private void pdfXChangeEditor_Leave(object sender, EventArgs e)
        {
            Debug.WriteLine("pdfXChangeEditor_Leave");
        }

        private void pdfXChangeEditor_OnEvent(object sender, AxPDFXEdit._IPXV_ControlEvents_OnEventEvent e)
        {
            Debug.WriteLine("pdfXChangeEditor_OnEvent");
        }
Almost as if the event is not registered, but it is in the designer file...

Code: Select all

            //
            // pdfXChangeEditor
            //
            resources.ApplyResources(this.pdfXChangeEditor, "pdfXChangeEditor");
            this.pdfXChangeEditor.Name = "pdfXChangeEditor";
            this.pdfXChangeEditor.OcxState = ((System.Windows.Forms.AxHost.State)(resources.GetObject("pdfXChangeEditor.OcxState")));
            this.pdfXChangeEditor.OnEvent += new AxPDFXEdit._IPXV_ControlEvents_OnEventEventHandler(this.pdfXChangeEditor_OnEvent);
            this.pdfXChangeEditor.VisibleChanged += new System.EventHandler(this.pdfXChangeEditor_VisibleChanged);
            this.pdfXChangeEditor.Enter += new System.EventHandler(this.pdfXChangeEditor_Enter);
            this.pdfXChangeEditor.Leave += new System.EventHandler(this.pdfXChangeEditor_Leave);
            this.pdfXChangeEditor.Resize += new System.EventHandler(this.pdfXChangeEditor_Resize);
Is there anything special about this specific event that perhaps requires more setup or configuration?
Sasha - Tracker Dev Team
User
Posts: 5522
Joined: Fri Nov 21, 2014 8:27 am
Contact:

Re: Changing Identity.Name no longer working?

Post by Sasha - Tracker Dev Team »

Hello JGForwick,

You should never store the numeric ID value between sessions. The IDs should be generated dynamically from their string values via the Str2ID method on the start of the program or where you needed it. The numeric values will differ from build to build so they should not be used directly.

Cheers,
Alex
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
Post Reply