|
@@ -693,6 +693,60 @@ namespace PDF_Master.ViewModels.Tools
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ //获取选中文字内容的区域大小,以及内容内容所在的页码
|
|
|
|
+ private Tuple<int, Rect> DrawRectCreateAnnot()
|
|
|
|
+ {
|
|
|
|
+ List<TextSelectNode> selectList = PDFViewer.GetSelectTextInfo();
|
|
|
|
+ Rect clientRect = Rect.Empty;
|
|
|
|
+ int pageIndex = -1;
|
|
|
|
+ if (selectList != null && selectList.Count > 0)
|
|
|
|
+ {
|
|
|
|
+ pageIndex = selectList[0].PageIndex;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ if (selectList != null && selectList.Count > 0)
|
|
|
|
+ {
|
|
|
|
+ foreach (TextSelectNode selectNode in selectList)
|
|
|
|
+ {
|
|
|
|
+
|
|
|
|
+ foreach (Rect rawRect in selectNode.RawRect)
|
|
|
|
+ {
|
|
|
|
+ clientRect.Union(rawRect);
|
|
|
|
+ }
|
|
|
|
+ int dpi = DpiHelpers.Dpi;
|
|
|
|
+ if (clientRect.IsEmpty == false)
|
|
|
|
+ {
|
|
|
|
+ clientRect = new Rect(
|
|
|
|
+ clientRect.Left / 72D * dpi,
|
|
|
|
+ clientRect.Top / 72D * dpi,
|
|
|
|
+ clientRect.Width / 72D * dpi,
|
|
|
|
+ clientRect.Height / 72D * dpi);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (clientRect != Rect.Empty && pageIndex > -1)
|
|
|
|
+ {
|
|
|
|
+ return new Tuple<int, Rect>(pageIndex, clientRect);
|
|
|
|
+ }
|
|
|
|
+ return null;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ //根据选中的文本内容,来创建指定大小的注释。
|
|
|
|
+ private void CreateAnnotFromSelectPageText(AnnotHandlerEventArgs annotArgs)
|
|
|
|
+ {
|
|
|
|
+ //点击注释工具,在阅读页根据选中的文本内容,创建注释矩形大小
|
|
|
|
+ var drawRectTuple = DrawRectCreateAnnot();
|
|
|
|
+ if (drawRectTuple != null)
|
|
|
|
+ {
|
|
|
|
+ annotArgs.ClientRect = drawRectTuple.Item2;
|
|
|
|
+ PDFViewer.CreatePageAnnot(drawRectTuple.Item1, annotArgs);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
//Event导航到填写与签名的属性面板
|
|
//Event导航到填写与签名的属性面板
|
|
private bool NavigatedToFillAndSignVM(List<AnnotHandlerEventArgs> annots, string tag)
|
|
private bool NavigatedToFillAndSignVM(List<AnnotHandlerEventArgs> annots, string tag)
|
|
{
|
|
{
|
|
@@ -851,6 +905,7 @@ namespace PDF_Master.ViewModels.Tools
|
|
{
|
|
{
|
|
selectedArgs = new List<AnnotHandlerEventArgs>();
|
|
selectedArgs = new List<AnnotHandlerEventArgs>();
|
|
selectedArgs.Add(squareArgs);
|
|
selectedArgs.Add(squareArgs);
|
|
|
|
+ CreateAnnotFromSelectPageText(squareArgs);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
else
|
|
else
|