I am currently developing an own PDF-XChange Editor-plugin for digital signatures from DocuSign (PDFXEditControl.Inst.AddPlugin(myDocuSignPlugin) and need for it to listen and get an annot. I
made this work, if embedd the PDFXEditControl control with this code:
Code: Select all
private int _idEventAnnotInserted;
private void frmMain_Load(object sender, EventArgs e)
{
PDFXEditControl.VisibleCmdPanes = PXV_VisibleCmdPanes.PXV_VisibleCmdPanes_All;
PDFXEditControl.OpenDocFromPath(@"C:\Temp\Vorlage_0383_03.pdf");
// Get event and save event-id for listening
_idEventAnnotInserted = PDFXEditControl.Inst.Str2ID("e.annots.inserted");
PDFXEditControl.EnableEventListening2(_idEventAnnotInserted, true);
}
private void PDFXEditControl_OnEvent(object sender, _IPXV_ControlEvents_OnEventEvent e)
{
if (e.nEventID == _idEventAnnotInserted)
{
// Listen for new added annot with event-id
PDFXEdit.IPXV_AnnotsEvent annotsEvent = (IPXV_AnnotsEvent)e.pEvent;
if (!annotsEvent == null)
{
// Get annot from event
IPXC_Annotation annot = annotsEvent.Items(annotsEvent.Items.Count - 1);
Debug.WriteLine(annot.Rect.left);
Debug.WriteLine(annot.Rect.top);
Debug.WriteLine("New annot with name '" + annot.Name + "' inserted!");
}
}
}
But I can't make the same work in my plugin and it drives me crazy.
I tried this but without success:
Code: Select all
public void Setup(PXV_Inst pInstance)
{
IUIX_Inst uixInstance = pInstance.GetExtension("UIX");
// Create custom event for listening
uixInstance.CurrentThreadCtx.RegisterEventMonitor(new CustomEventMonitor(pInstance));
}
public class CustomEventMonitor : PDFXEdit.IUIX_EventMonitor
{
public void OnEventMonitor(IUIX_Obj pTarget, IUIX_Event pEvent)
{
Debug.WriteLine(_uixInstance.ID2Str(pTarget.ID));
// Get mouse click event instead of AnnotEvent
if (pEvent.Code == System.Convert.ToUInt32(UIX_EventCodes.e_MouseCaptureLost))
{
IPXV_PagesLayoutManager activePageLayout = _pxvInstance.ActiveDocView.PagesView.Layout;
PDFXEdit.IPXC_Page pdfPage = _pxvInstance.ActiveDoc.CoreDoc.Pages(activePageLayout.CurrentPage);
uint nAnnotCount = pdfPage.GetAnnotsCount();
if (nAnnotCount != 0)
{
for (uint i = 0; i <= nAnnotCount - 1; i++)
{
PDFXEdit.IPXC_Annotation annot = pdfPage.GetAnnot(i);
PXC_Rect myRect = annot.Rect;
}
}
}
}
}
Code: Select all
if (pEvent.Code == System.Convert.ToUInt32(UIX_EventCodes.e_MouseCaptureLost))
(Easiest would be that I can listen to OnEvent from the PDFXEditControl in my plugin but I am afraid this would work)
Best regards,
Karl