Selaa lähdekoodia

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

liyuxuan 2 kuukautta sitten
vanhempi
commit
afbc56e4c5
1 muutettua tiedostoa jossa 13 lisäystä ja 0 poistoa
  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;