Execute link annotation actions from code SOLVED
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.
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.
-
- User
- Posts: 1370
- Joined: Thu Sep 05, 2019 12:35 pm
Execute link annotation actions from code
Hi Support,
How do I mimic link annotation click - to execute actions it has?
p.s.
Similar to, if I'm not wrong, what "cmd.bookmarksView.goto" does for a selected bookmark.
-ž
How do I mimic link annotation click - to execute actions it has?
p.s.
Similar to, if I'm not wrong, what "cmd.bookmarksView.goto" does for a selected bookmark.
-ž
-
- User
- Posts: 1370
- Joined: Thu Sep 05, 2019 12:35 pm
Re: Execute link annotation actions from code
Hi Support,
I've tried IPXV_ActionHandler::Perform but it either fails with an error "parameter incorrect" or no error but nothing happens (e.document.beforeRunAction does not fire).
Since an annot can have multiple actions I would need to know what parameters (in Perform) to use for each - if the above is the way to go.
-ž
I've tried IPXV_ActionHandler::Perform but it either fails with an error "parameter incorrect" or no error but nothing happens (e.document.beforeRunAction does not fire).
Since an annot can have multiple actions I would need to know what parameters (in Perform) to use for each - if the above is the way to go.
-ž
-
- User
- Posts: 5522
- Joined: Fri Nov 21, 2014 8:27 am
- Contact:
Re: Execute link annotation actions from code
Hello zarkogajic,
Hmm, I don't see any problem with the Perform method:
Cheers,
Alex
Hmm, I don't see any problem with the Perform method:
Code: Select all
private void addLinkAnnotToolStripMenuItem_Click(object sender, EventArgs e)
{
PDFXEdit.IPXS_Inst pSInt = (PDFXEdit.IPXS_Inst)pdfCtl.Inst.GetExtension("PXS");
//Getting Free Text annotation atom for the InsertNewAnnot method
uint nLink = pSInt.StrToAtom("Link");
PDFXEdit.IPXC_Page pPage = pdfCtl.Doc.CoreDoc.Pages[0];
PDFXEdit.PXC_Rect rc;
rc.left = 0;
rc.right = 150;
rc.top = 150;
rc.bottom = 0;
PDFXEdit.IPXC_Annotation pAnnot = pPage.InsertNewAnnot(nLink, ref rc, 0);
if (pAnnot == null)
return;
//Filling the annotation with needed text
PDFXEdit.IPXC_AnnotData_Link FTData = (PDFXEdit.IPXC_AnnotData_Link)pAnnot.Data;
FTData.Contents = "https://www.google.com";
PDFXEdit.IPXC_ActionsList AL = pdfCtl.Doc.CoreDoc.CreateActionsList();
PDFXEdit.IPXC_Action uri = AL.AddURI("https://www.google.com");
pAnnot.set_Actions(PDFXEdit.PXC_TriggerType.Trigger_Up, AL);
PDFXEdit.PXC_AnnotBorder border = new PDFXEdit.PXC_AnnotBorder();
border.nStyle = PDFXEdit.PXC_AnnotBorderStyle.ABS_Underline;
border.nWidth = 2;
FTData.set_Border(ref border);
PDFXEdit.IColor color = auxInst.CreateColor(PDFXEdit.ColorType.ColorType_RGB);
color.SetRGB(0.0f, 0.0f, 1.0f);
FTData.Color = color;
pAnnot.Data = FTData;
//Executing the operation so that the annotation will be updated from structure
int nID = pdfCtl.Inst.Str2ID("op.annots.addNew", false);
PDFXEdit.IOperation pOp = pdfCtl.Inst.CreateOp(nID);
PDFXEdit.ICabNode input = pOp.Params.Root["Input"];
input.Add().v = pAnnot;
pOp.Do();
IPXV_ActionHandler handler = pdfCtl.Inst.GetHandlerForAction(uri.Type);
handler.Perform(pdfCtl.Doc, uri, null, 0, 0);
}
Alex
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
-
- User
- Posts: 1370
- Joined: Thu Sep 05, 2019 12:35 pm
Re: Execute link annotation actions from code
Thanks Alex,
I'll give it another try ...
Anyhow, nothing like "cmd.bookmarksView.goto" for link annots ?
-žarko
I'll give it another try ...
Anyhow, nothing like "cmd.bookmarksView.goto" for link annots ?
-žarko
-
- User
- Posts: 5522
- Joined: Fri Nov 21, 2014 8:27 am
- Contact:
Re: Execute link annotation actions from code
Hello zarkogajic,
The IPXV_ActionHandler::Perform method will do just that.
Cheers,
Alex
The IPXV_ActionHandler::Perform method will do just that.
Cheers,
Alex
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
-
- User
- Posts: 1370
- Joined: Thu Sep 05, 2019 12:35 pm
Re: Execute link annotation actions from code
Hi Alex,
Thanks. I was setting the nClass (PAEC_Link) and nSubclass (PAESC_MouseUp) parameters in my test-try.
Once I've cleared those out it started to work.
However, the e.document.beforeRunAction does *not* get fired - and I need it to happen so I can custom handle what will happen...
-žarko
Thanks. I was setting the nClass (PAEC_Link) and nSubclass (PAESC_MouseUp) parameters in my test-try.
Once I've cleared those out it started to work.
However, the e.document.beforeRunAction does *not* get fired - and I need it to happen so I can custom handle what will happen...
-žarko
-
- User
- Posts: 1370
- Joined: Thu Sep 05, 2019 12:35 pm
Re: Execute link annotation actions from code
Hi Alex,
I've "fixed" this by calling the same code I use in "e.document.beforeRunAction" - sending it the ipxc_action to for those I want to custom handle and calling Perform for the rest. So consider solved.
But do please confirm that Perform not raising the event is by design?
Ž
I've "fixed" this by calling the same code I use in "e.document.beforeRunAction" - sending it the ipxc_action to for those I want to custom handle and calling Perform for the rest. So consider solved.
But do please confirm that Perform not raising the event is by design?
Ž
-
- User
- Posts: 5522
- Joined: Fri Nov 21, 2014 8:27 am
- Contact:
Re: Execute link annotation actions from code
Hello zarkogajic,
It does not raise it internally. Also, do not forget about the https://sdkhelp.pdf-xchange.com/vi ... rRunAction event that you should fire afterwards.
Cheers,
Alex
It does not raise it internally. Also, do not forget about the https://sdkhelp.pdf-xchange.com/vi ... rRunAction event that you should fire afterwards.
Cheers,
Alex
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
-
- User
- Posts: 1370
- Joined: Thu Sep 05, 2019 12:35 pm
Re: Execute link annotation actions from code
Hi Alex,
How to do it (and why)?
ž
How to do it (and why)?
ž
-
- User
- Posts: 5522
- Joined: Fri Nov 21, 2014 8:27 am
- Contact:
Re: Execute link annotation actions from code
Hello zarkogajic,
Well in case that you want to emulate the fully correct behavior, you would have to construct and fire your before/after events. That is if you need that.
Cheers,
Alex
Well in case that you want to emulate the fully correct behavior, you would have to construct and fire your before/after events. That is if you need that.
Cheers,
Alex
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
-
- User
- Posts: 1370
- Joined: Thu Sep 05, 2019 12:35 pm
Re: Execute link annotation actions from code
Yes, I thought of doing that, I'm just not sure how to fire the needed events. So, a code sample, please.
ž
ž
-
- User
- Posts: 5522
- Joined: Fri Nov 21, 2014 8:27 am
- Contact:
Re: Execute link annotation actions from code
Hello zarkogajic,
Here's a code sample that I had on this matter:
Cheers,
Alex
Here's a code sample that I had on this matter:
Code: Select all
pdfCtl.Doc.CoreDoc.Props.set_ViewPrefFlag(PDFXEdit.PXC_DocumentViewFlags.DocViewFlag_DisplayDocTitle, true);
pdfCtl.Doc.CoreDoc.SrcInfo.CustDispTitle = "Custom Title";
var evtID = pdfCtl.Inst.Str2ID("e.document.propsChanged", false);
IntPtr unkPtr = System.Runtime.InteropServices.Marshal.GetIUnknownForObject(pdfCtl.Doc);
PDFXEdit.IEvent evt = pdfCtl.Doc.EventServer.CreateNewEvent(evtID, (uint)unkPtr, (uint)PDFXEdit.PXC_DocumentViewFlags.DocViewFlag_DisplayDocTitle);
pdfCtl.Doc.EventServer.FireEvent(evt, pdfCtl.Doc);
Alex
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
-
- User
- Posts: 1370
- Joined: Thu Sep 05, 2019 12:35 pm
Re: Execute link annotation actions from code
Hi Alex,
Yes, but I need to fire an IPXV_DocActionEvent - and I'm not sure how to create one of such kind.
Should I create a class implementing IPXV_DocActionEvent?
Then:
1. CreateNewEvent -> returns iEvent
2. Use it in my custom IPXV_DocActionEvent implementation ( + setting Action, TriggerClass, TriggerSubclass and ActionData)
3. FireEvent (my IPXV_DocActionEvent event)
If so, what should be the last parameter value in CreateNewEvent ?
-ž
Yes, but I need to fire an IPXV_DocActionEvent - and I'm not sure how to create one of such kind.
Should I create a class implementing IPXV_DocActionEvent?
Then:
1. CreateNewEvent -> returns iEvent
2. Use it in my custom IPXV_DocActionEvent implementation ( + setting Action, TriggerClass, TriggerSubclass and ActionData)
3. FireEvent (my IPXV_DocActionEvent event)
If so, what should be the last parameter value in CreateNewEvent ?
-ž
-
- User
- Posts: 5522
- Joined: Fri Nov 21, 2014 8:27 am
- Contact:
Re: Execute link annotation actions from code
Hello zarkogajic,
The CreateEvent will return an already implemented interface that you only need to set with your needed data.
BTW...
Just found the IPXV_Inst::PerformActions method that will do the events firing and all of the needed work.
Cheers,
Alex
The CreateEvent will return an already implemented interface that you only need to set with your needed data.
BTW...
Just found the IPXV_Inst::PerformActions method that will do the events firing and all of the needed work.
Cheers,
Alex
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
-
- User
- Posts: 1370
- Joined: Thu Sep 05, 2019 12:35 pm
Re: Execute link annotation actions from code SOLVED
Hi Alex,
Yes, PerformActions is the way to go, thanks!
-ž
Yes, PerformActions is the way to go, thanks!
-ž
-
- User
- Posts: 5522
- Joined: Fri Nov 21, 2014 8:27 am
- Contact:
Re: Execute link annotation actions from code
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ