소스 검색

ComPDFKit.Tool(Win) - 粘贴形状注释时获取注释范围下文字

liyuxuan 2 달 전
부모
커밋
afbc56e4c5
1개의 변경된 파일13개의 추가작업 그리고 0개의 파일을 삭제
  1. 13 0
      Demo/Examples/ComPDFKit.Tool/CPDFViewerTool.Command.cs

+ 13 - 0
Demo/Examples/ComPDFKit.Tool/CPDFViewerTool.Command.cs

@@ -1415,6 +1415,13 @@ namespace ComPDFKit.Tool
                             CPDFAnnotation cPDFAnnotation = cPDFPage.CreateAnnot(item.CurrentType);
                             CreateDefaultAnnot(cPDFAnnotation, item.CurrentType, item);
                             cPDFAnnotation.SetRect(setRect);
+                            CPDFTextPage textPage = cPDFPage.GetTextPage();
+                            if (textPage != null)
+                            {
+                                string newContent = textPage.GetBoundedText(setRect);
+                                cPDFAnnotation.SetContent(newContent);
+                            }
+
                             cPDFAnnotation.UpdateAp();
                             AnnotParam annotParam = ParamConverter.AnnotConverter(cPDFDocument, cPDFAnnotation);
                             (annotHistory as SquareAnnotHistory).CurrentParam = (SquareParam)annotParam;
@@ -1459,6 +1466,12 @@ namespace ComPDFKit.Tool
                             CPDFAnnotation cPDFAnnotation = cPDFPage.CreateAnnot(item.CurrentType);
                             CreateDefaultAnnot(cPDFAnnotation, item.CurrentType, item);
                             cPDFAnnotation.SetRect(setRect);
+                            CPDFTextPage textPage = cPDFPage.GetTextPage();
+                            if (textPage != null)
+                            {
+                                string newContent = textPage.GetBoundedText(setRect);
+                                cPDFAnnotation.SetContent(newContent);
+                            }
                             cPDFAnnotation.UpdateAp();
                             AnnotParam annotParam = ParamConverter.AnnotConverter(cPDFDocument, cPDFAnnotation);
                             (annotHistory as CircleAnnotHistory).CurrentParam = (CircleParam)annotParam;