|
@@ -21,6 +21,9 @@ using ComPDFKit.Measure;
|
|
using System.Dynamic;
|
|
using System.Dynamic;
|
|
using System.Globalization;
|
|
using System.Globalization;
|
|
using System.Windows.Controls;
|
|
using System.Windows.Controls;
|
|
|
|
+using ComPDFKitViewer;
|
|
|
|
+using System.Reflection;
|
|
|
|
+using ComPDFKit.PDFDocument.Action;
|
|
|
|
|
|
namespace ComPDFKit.Tool
|
|
namespace ComPDFKit.Tool
|
|
{
|
|
{
|
|
@@ -2082,5 +2085,91 @@ namespace ComPDFKit.Tool
|
|
|
|
|
|
MouseRightButtonDownHandler?.Invoke(sender, e);
|
|
MouseRightButtonDownHandler?.Invoke(sender, e);
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ public void CreateLinkAnnotWithImage(int pageIndex, CRect rawImageRect)
|
|
|
|
+ {
|
|
|
|
+ if(viewerTool == null)
|
|
|
|
+ {
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ viewerTool.RemoveSelectTextData();
|
|
|
|
+ viewerTool.ReDrawSelectText();
|
|
|
|
+ viewerTool.HideWidgetHitPop();
|
|
|
|
+
|
|
|
|
+ CPDFViewer pdfViewer = viewerTool.GetCPDFViewer();
|
|
|
|
+ CPDFDocument cPDFDocument = pdfViewer.GetDocument();
|
|
|
|
+ CPDFPage cPDFPage = cPDFDocument.PageAtIndex(pageIndex);
|
|
|
|
+ CPDFLinkAnnotation linkAnnot = cPDFPage.CreateAnnot(C_ANNOTATION_TYPE.C_ANNOTATION_LINK) as CPDFLinkAnnotation;
|
|
|
|
+ if (linkAnnot != null)
|
|
|
|
+ {
|
|
|
|
+ linkAnnot.SetCreationDate(PDFHelp.GetCurrentPdfTime());
|
|
|
|
+ linkAnnot.SetModifyDate(PDFHelp.GetCurrentPdfTime());
|
|
|
|
+ List<CPDFAnnotation> annotList = cPDFPage.GetAnnotations();
|
|
|
|
+ int newIndex = cPDFPage.GetAnnotCount();
|
|
|
|
+ linkAnnot.SetRect(rawImageRect);
|
|
|
|
+
|
|
|
|
+ DefaultSettingParam defaultSettingParam = viewerTool.GetDefaultSettingParam();
|
|
|
|
+
|
|
|
|
+ LinkParam linkParam = defaultSettingParam.LinkParamDef;
|
|
|
|
+ switch (linkParam.Action)
|
|
|
|
+ {
|
|
|
|
+ case C_ACTION_TYPE.ACTION_TYPE_GOTO:
|
|
|
|
+ CPDFGoToAction gotoAction = new CPDFGoToAction();
|
|
|
|
+ CPDFDestination destination = new CPDFDestination();
|
|
|
|
+ destination.Position_X = linkParam.DestinationPosition.x;
|
|
|
|
+ destination.Position_Y = linkParam.DestinationPosition.y;
|
|
|
|
+ destination.PageIndex = linkParam.DestinationPageIndex;
|
|
|
|
+ gotoAction.SetDestination(cPDFDocument, destination);
|
|
|
|
+ linkAnnot.SetLinkAction(gotoAction);
|
|
|
|
+ break;
|
|
|
|
+ case C_ACTION_TYPE.ACTION_TYPE_URI:
|
|
|
|
+ CPDFUriAction uriAction = new CPDFUriAction();
|
|
|
|
+ if (!string.IsNullOrEmpty(linkParam.Uri))
|
|
|
|
+ {
|
|
|
|
+ uriAction.SetUri(linkParam.Uri);
|
|
|
|
+ }
|
|
|
|
+ linkAnnot.SetLinkAction(uriAction);
|
|
|
|
+ break;
|
|
|
|
+ default:
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (!string.IsNullOrEmpty(linkParam.Content))
|
|
|
|
+ {
|
|
|
|
+ linkAnnot.SetContent(linkParam.Content);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (!string.IsNullOrEmpty(linkParam.Author))
|
|
|
|
+ {
|
|
|
|
+ linkAnnot.SetAuthor(linkParam.Author);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (!string.IsNullOrEmpty(linkParam.CreateTime))
|
|
|
|
+ {
|
|
|
|
+ linkAnnot.SetCreationDate(linkParam.CreateTime);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (!string.IsNullOrEmpty(linkParam.UpdateTime))
|
|
|
|
+ {
|
|
|
|
+ linkAnnot.SetModifyDate(linkParam.UpdateTime);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ linkAnnot.SetIsLocked(linkParam.Locked);
|
|
|
|
+ linkAnnot.SetTransparency(linkParam.Transparency);
|
|
|
|
+ MouseEventObject e= new MouseEventObject();
|
|
|
|
+ e.hitTestType = MouseHitTestType.Annot;
|
|
|
|
+ e.annotType = C_ANNOTATION_TYPE.C_ANNOTATION_LINK;
|
|
|
|
+ e.IsCreate = true;
|
|
|
|
+ AnnotParam annotParam = ParamConverter.AnnotConverter(viewerTool.GetCPDFViewer().GetDocument(), linkAnnot);
|
|
|
|
+ dynamic expandData = new ExpandoObject();
|
|
|
|
+ expandData.AnnotIndex = newIndex;
|
|
|
|
+ expandData.PageIndex=pageIndex;
|
|
|
|
+ expandData.AnnotParam= annotParam;
|
|
|
|
+ e.Data = expandData;
|
|
|
|
+
|
|
|
|
+ MouseLeftButtonUpHandler?.Invoke(this, e);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
}
|
|
}
|
|
}
|
|
}
|