Browse Source

PDFView Flutter - 密文注释

liuxiaolong 1 year ago
parent
commit
207b19573f

+ 0 - 1
android/app/src/main/kotlin/com/compdfkit/pdfviewer/flutter/helpers/AnnotAttributeUtil.kt

@@ -213,7 +213,6 @@ object AnnotAttributeUtil {
                     if (standardStamp.isNullOrEmpty().not()){
                         cpdfReaderView.readerAttribute.annotAttribute.stampAttr.standardStamp = com.compdfkit.core.annotation.CPDFStampAnnotation.StandardStamp.valueOf(standardStamp!!.uppercase())
                     }else{
-                        val time = System.currentTimeMillis()
                         val textStampContent = entry.value.getString(PluginUtils.EVENT_ANNOT_ATTR_TEXT_STAMP_CONTENT)
                         val textStampDate = entry.value.getString(PluginUtils.EVENT_ANNOT_ATTR_TEXT_STAMP_DATE)
                         val textStampStyleShapeType = entry.value.getString(PluginUtils.EVENT_ANNOT_ATTR_TEXT_STAMP_STYLE_SHAPE_TYPE)

+ 2 - 1
android/app/src/main/kotlin/com/compdfkit/pdfviewer/flutter/helpers/Constains.kt

@@ -25,7 +25,8 @@ enum class AnnotType {
     FREETEXT,
     SIGNATURE,
     STAMP,
-    LINK
+    LINK,
+    REDACT
 
 }
 

+ 13 - 0
assets/images/ic_reader_redact.svg

@@ -0,0 +1,13 @@
+<?xml version="1.0" standalone="no"?>
+<svg version="1.0" xmlns="http://www.w3.org/2000/svg" width="200.000000pt" height="200.000000pt" viewBox="0 0 200.000000 200.000000" preserveAspectRatio="xMidYMid meet">
+    <rect width="200" height="200" fill="#EFF4FD"/>
+    <g transform="translate(0.000000,200.000000) scale(0.100000,-0.100000)" fill="#273C62" stroke="none">
+        <path d="M895 1989 c-190 -18 -400 -109 -545 -235 -391 -342 -457 -929 -151
+-1341 71 -97 113 -139 214 -214 538 -402 1332 -145 1532 496 166 528 -118
+1085 -636 1249 -59 19 -137 37 -175 40 -38 4 -87 8 -109 10 -22 2 -80 0 -130
+-5z m595 -496 c55 -55 78 -87 82 -109 10 -73 1 -84 -335 -422 l-322 -322 -137
+137 -138 138 297 298 c164 165 316 312 337 328 31 23 50 29 89 29 48 0 51 -2
+127 -77z m-655 -924 c-32 -35 -67 -47 -194 -71 -117 -21 -121 -22 -141 -3 -27
+24 -26 64 5 199 19 85 31 116 52 138 l27 29 135 -135 135 -135 -19 -22z" />
+    </g>
+</svg>

+ 13 - 0
assets/images/ic_reader_redact_select.svg

@@ -0,0 +1,13 @@
+<?xml version="1.0" standalone="no"?>
+<svg version="1.0" xmlns="http://www.w3.org/2000/svg" width="200.000000pt" height="200.000000pt" viewBox="0 0 200.000000 200.000000" preserveAspectRatio="xMidYMid meet">
+    <rect width="200" height="200" fill="#D5E3FE"/>
+    <g transform="translate(0.000000,200.000000) scale(0.100000,-0.100000)" fill="#273C62" stroke="none">
+        <path d="M895 1989 c-190 -18 -400 -109 -545 -235 -391 -342 -457 -929 -151
+-1341 71 -97 113 -139 214 -214 538 -402 1332 -145 1532 496 166 528 -118
+1085 -636 1249 -59 19 -137 37 -175 40 -38 4 -87 8 -109 10 -22 2 -80 0 -130
+-5z m595 -496 c55 -55 78 -87 82 -109 10 -73 1 -84 -335 -422 l-322 -322 -137
+137 -138 138 297 298 c164 165 316 312 337 328 31 23 50 29 89 29 48 0 51 -2
+127 -77z m-655 -924 c-32 -35 -67 -47 -194 -71 -117 -21 -121 -22 -141 -3 -27
+24 -26 64 5 199 19 85 31 116 52 138 l27 29 135 -135 135 -135 -19 -22z" />
+    </g>
+</svg>

+ 3 - 1
lib/widgets/contains.dart

@@ -104,7 +104,8 @@ enum AnnotationType {
   freetext,
   signature,
   stamp,
-  link
+  link,
+  redact
 
 
 }
@@ -152,6 +153,7 @@ enum StandardStamp {
   privateradiomark,
 }
 
+
 enum LinkType {
   page,
   website,

+ 18 - 18
lib/widgets/function/pdf_bottom_annot_fun_widget.dart

@@ -69,17 +69,26 @@ class _PDFBottomAnnotFunWidgetState extends State<PDFBottomAnnotFunWidget> {
         annotType: AnnotationType.signature,
         normalImagePath: 'assets/images/ic_reader_signature.svg',
         selectImagePath: 'assets/images/ic_reader_signature_select.svg',
-        attributeBean: AnnotAttributeBean(color: Colors.transparent)),
+        attributeBean: AnnotAttributeBean(
+            color: Colors.transparent, shapeType: AnnotationType.signature)),
     AnnotBean(
         annotType: AnnotationType.stamp,
         normalImagePath: 'assets/images/ic_reader_stamp.svg',
         selectImagePath: 'assets/images/ic_reader_stamp_select.svg',
-        attributeBean: AnnotAttributeBean(color: Colors.transparent)),
+        attributeBean: AnnotAttributeBean(
+            color: Colors.transparent, shapeType: AnnotationType.stamp)),
     AnnotBean(
         annotType: AnnotationType.link,
         normalImagePath: 'assets/images/ic_reader_link.svg',
         selectImagePath: 'assets/images/ic_reader_link_select.svg',
-        attributeBean: AnnotAttributeBean(color: Colors.transparent)),
+        attributeBean: AnnotAttributeBean(
+            color: Colors.transparent, shapeType: AnnotationType.link)),
+    AnnotBean(
+        annotType: AnnotationType.redact,
+        normalImagePath: 'assets/images/ic_reader_redact.svg',
+        selectImagePath: 'assets/images/ic_reader_redact_select.svg',
+        attributeBean: AnnotAttributeBean(
+            color: Colors.transparent, shapeType: AnnotationType.redact)),
   ];
 
   @override
@@ -128,7 +137,9 @@ class _PDFBottomAnnotFunWidgetState extends State<PDFBottomAnnotFunWidget> {
       setState(() {
         selectAnnot = annotBean.annotType;
       });
-      showAttributeModalBottomSheet(context, annotBean);
+      if(selectAnnot != AnnotationType.link && selectAnnot != AnnotationType.redact){
+        showAttributeModalBottomSheet(context, annotBean);
+      }
     });
   }
 
@@ -206,8 +217,10 @@ class _PDFBottomAnnotFunWidgetState extends State<PDFBottomAnnotFunWidget> {
       });
     }, () {
       setState(() {
-        if (selectAnnot == AnnotationType.signature) {
+        if (selectAnnot == AnnotationType.signature ||
+            selectAnnot == AnnotationType.stamp) {
           selectAnnot = AnnotationType.unknown;
+          setCPDFReaderViewFocusType(selectAnnot);
         }
       });
     });
@@ -262,10 +275,6 @@ class _PDFBottomAnnotFunWidgetState extends State<PDFBottomAnnotFunWidget> {
     AnnotAttributeBean shape = await getAnnotAttribute(AnnotationType.shape);
     AnnotAttributeBean freeText =
         await getAnnotAttribute(AnnotationType.freetext);
-    AnnotAttributeBean signature =
-        await getAnnotAttribute(AnnotationType.signature);
-    AnnotAttributeBean stamp = await getAnnotAttribute(AnnotationType.stamp);
-    AnnotAttributeBean link = await getAnnotAttribute(AnnotationType.link);
     setState(() {
       for (var element in annotFunList) {
         switch (element.annotType) {
@@ -292,15 +301,6 @@ class _PDFBottomAnnotFunWidgetState extends State<PDFBottomAnnotFunWidget> {
           case AnnotationType.freetext:
             element.attributeBean = freeText;
             break;
-          case AnnotationType.signature:
-            element.attributeBean = signature;
-            break;
-          case AnnotationType.stamp:
-            element.attributeBean = stamp;
-            break;
-          case AnnotationType.link:
-            element.attributeBean = link;
-            break;
           default:
             break;
         }

+ 2 - 0
lib/widgets/models/annot_attribute_bean.dart

@@ -247,6 +247,8 @@ class AnnotAttributeBean {
         }
       case AnnotationType.unknown:
         return {};
+      default:
+        return {};
     }
   }
 }