3 Revize 1e8479775d ... 26c460185e

Autor SHA1 Zpráva Datum
  liutian 26c460185e fix: 字体使用更新区分压缩和未压缩 před 1 měsícem
  liutian 669b7299cf add před 1 měsícem
  wzl 1e8479775d update: Form用外观图片展示 před 1 měsícem

+ 0 - 3
packages/core/src/TextSelection.ts

@@ -209,14 +209,11 @@ export default class TextSelection {
   }
 
   async handleMouseMove(event: MouseEvent) {
-    if (this.isTargetInElement(event.target, '.redaction-confirm-dialog') || this.isTargetInElement(event.target, '.mask')) return
-
     const inPage = this.testPoint(event)
     if (!inPage || document.querySelector('.annotationContainer .outline-container')) {
       this.container?.classList.remove('text')
       return
     }
-
     const { x, y } = inPage
     const point = getInitialPoint({ x, y }, this.viewport, this.scale)
     const isText = await this.isTextAtPoint(point)

+ 14 - 29
packages/core/src/annotation/layer.js

@@ -64,7 +64,6 @@ class ComPDFAnnotationLayer {
     this.addMode = false
     this.toolMode = pageViewer.toolMode || ''
     this.managerArray = ['freetextManager', 'textManager', 'textFieldManager', 'checkBoxManager', 'radioButtonManager', 'pushButtonManager', 'listBoxManager', 'comboBoxManager', 'annotateManager', 'linkManager', 'signFieldManager', 'redactionManager']
-    this.ratio = window.devicePixelRatio || 1
 
     this.annotationStore = annotationStore
 
@@ -501,8 +500,7 @@ class ComPDFAnnotationLayer {
             scale: this.scale,
             eventBus: this.eventBus,
             layer: this,
-            highlight: this.annotationStore.highlightForm,
-            messageHandler: this.messageHandler
+            highlight: this.annotationStore.highlightForm
           })
           this.annotationsArray.push(textfield)
         }
@@ -515,8 +513,7 @@ class ComPDFAnnotationLayer {
             scale: this.scale,
             eventBus: this.eventBus,
             layer: this,
-            highlight: this.annotationStore.highlightForm,
-            messageHandler: this.messageHandler
+            highlight: this.annotationStore.highlightForm
           })
           this.annotationsArray.push(checkbox)
         }
@@ -529,8 +526,7 @@ class ComPDFAnnotationLayer {
             scale: this.scale,
             eventBus: this.eventBus,
             layer: this,
-            highlight: this.annotationStore.highlightForm,
-            messageHandler: this.messageHandler
+            highlight: this.annotationStore.highlightForm
           })
           this.annotationsArray.push(radiobutton)
         }
@@ -543,8 +539,7 @@ class ComPDFAnnotationLayer {
             scale: this.scale,
             eventBus: this.eventBus,
             layer: this,
-            highlight: this.annotationStore.highlightForm,
-            messageHandler: this.messageHandler
+            highlight: this.annotationStore.highlightForm
           })
           this.annotationsArray.push(pushbutton)
         }
@@ -557,8 +552,7 @@ class ComPDFAnnotationLayer {
             scale: this.scale,
             eventBus: this.eventBus,
             layer: this,
-            highlight: this.annotationStore.highlightForm,
-            messageHandler: this.messageHandler
+            highlight: this.annotationStore.highlightForm
           })
           this.annotationsArray.push(listbox)
         }
@@ -571,8 +565,7 @@ class ComPDFAnnotationLayer {
             scale: this.scale,
             eventBus: this.eventBus,
             layer: this,
-            highlight: this.annotationStore.highlightForm,
-            messageHandler: this.messageHandler
+            highlight: this.annotationStore.highlightForm
           })
           this.annotationsArray.push(combobox)
         }
@@ -585,8 +578,7 @@ class ComPDFAnnotationLayer {
             scale: this.scale,
             eventBus: this.eventBus,
             layer: this,
-            highlight: this.annotationStore.highlightLink,
-            messageHandler: this.messageHandler
+            highlight: this.annotationStore.highlightLink
           })
           this.annotationsArray.push(link)
         }
@@ -805,8 +797,7 @@ class ComPDFAnnotationLayer {
         scale: this.scale,
         eventBus: this.eventBus,
         layer: this,
-        highlight: this.highlightForm,
-        messageHandler: this.messageHandler
+        highlight: this.highlightForm
       })
       this.annotationsArray.push(textfield)
     } else if (annotation.type === 'checkbox' && !annotation.isDelete) {
@@ -818,8 +809,7 @@ class ComPDFAnnotationLayer {
         scale: this.scale,
         eventBus: this.eventBus,
         layer: this,
-        highlight: this.annotationStore.highlightForm,
-        messageHandler: this.messageHandler
+        highlight: this.annotationStore.highlightForm
       })
       this.annotationsArray.push(checkbox)
     } else if (annotation.type === 'radiobutton' && !annotation.isDelete) {
@@ -831,8 +821,7 @@ class ComPDFAnnotationLayer {
         scale: this.scale,
         eventBus: this.eventBus,
         layer: this,
-        highlight: this.annotationStore.highlightForm,
-        messageHandler: this.messageHandler
+        highlight: this.annotationStore.highlightForm
       })
       this.annotationsArray.push(radiobutton)
     } else if (annotation.type === 'pushbutton' && !annotation.isDelete) {
@@ -845,8 +834,7 @@ class ComPDFAnnotationLayer {
         eventBus: this.eventBus,
         layer: this,
         show,
-        highlight: this.annotationStore.highlightForm,
-        messageHandler: this.messageHandler
+        highlight: this.annotationStore.highlightForm
       })
       this.annotationsArray.push(pushbutton)
     } else if (annotation.type === 'listbox' && !annotation.isDelete) {
@@ -859,8 +847,7 @@ class ComPDFAnnotationLayer {
         eventBus: this.eventBus,
         layer: this,
         show,
-        highlight: this.annotationStore.highlightForm,
-        messageHandler: this.messageHandler
+        highlight: this.annotationStore.highlightForm
       })
       this.annotationsArray.push(listbox)
     } else if (annotation.type === 'combobox' && !annotation.isDelete) {
@@ -873,8 +860,7 @@ class ComPDFAnnotationLayer {
         eventBus: this.eventBus,
         layer: this,
         show,
-        highlight: this.annotationStore.highlightForm,
-        messageHandler: this.messageHandler
+        highlight: this.annotationStore.highlightForm
       })
       this.annotationsArray.push(combobox)
     } else if (annotation.type === 'link' && !annotation.isDelete) {
@@ -887,8 +873,7 @@ class ComPDFAnnotationLayer {
         eventBus: this.eventBus,
         layer: this,
         show,
-        highlight: this.annotationStore.highlightLink,
-        messageHandler: this.messageHandler
+        highlight: this.annotationStore.highlightLink
       })
       this.annotationsArray.push(link)
     } else if (annotation.type === 'signatureFields' && !annotation.isDelete) {

+ 8 - 70
packages/core/src/form/check_box.js

@@ -13,8 +13,7 @@ export default class CheckBox extends Base {
     eventBus,
     layer,
     show = false,
-    highlight,
-    messageHandler
+    highlight
   }) {
     super({
       container,
@@ -28,7 +27,6 @@ export default class CheckBox extends Base {
     })
 
     this.layer = layer
-    this.messageHandler = messageHandler
     this.hidden = true
     this.initial = false
     this.outline = null
@@ -56,7 +54,7 @@ export default class CheckBox extends Base {
     this.render()
   }
 
-  async render () {
+  render () {
     this.eventBus._on('setProperty', this.setProperty)
     this.eventBus._on('setHighlightForm', this.setHighlight)
 
@@ -86,28 +84,10 @@ export default class CheckBox extends Base {
     this.annotationContainer = annotationContainer
     this.annotationContainer.addEventListener('mousedown', this.handleClick.bind(this))
 
-    let shapeElement
-    shapeElement = createElement(
-      'div',
-      {
-        left: 0,
-        top: 0,
-        width: `${Math.abs(rect.width)}px`,
-        height: `${Math.abs(rect.height)}px`,
-        position: 'relative'
-      }
-    )
-    this.shapeElement = shapeElement
-
-    this.getImage()
-    this.annotationContainer.append(this.shapeElement)
-    this.container.append(this.annotationContainer)
-
     let borderElement
     borderElement = createElement(
       'div',
       {
-        position: 'absolute',
         left: 0,
         top: 0,
         display: 'flex',
@@ -119,9 +99,10 @@ export default class CheckBox extends Base {
         borderWidth: annotation.borderWidth | 1 + 'px',
         borderStyle: annotation.borderStyle,
         backgroundColor: annotation.backgroundColor,
-        opacity: 0
+        position: 'relative'
       }
     )
+
     this.borderElement = borderElement
 
     // creat shape svg
@@ -138,6 +119,7 @@ export default class CheckBox extends Base {
         height: `${rect.height / 2}px`
       }
     )
+
     this.svgElement = svgElement
 
     // 填充的图形
@@ -205,7 +187,8 @@ export default class CheckBox extends Base {
     }
 
     this.borderElement.append(this.svgElement)
-    this.shapeElement.append(this.borderElement)
+    this.annotationContainer.append(this.borderElement)
+    this.container.append(this.annotationContainer)
 
     this.outerLineContainer = document.createElement('div')
     this.outerLineContainer.className = 'outline-container'
@@ -436,8 +419,7 @@ export default class CheckBox extends Base {
   };
 
   calculate (start, end) {
-    const initRect = this.rectCalc({ start, end })
-    this.initRect = initRect
+    const initRect = this.rectCalc({ start, end });
     const actualBdWidth = (this.annotation.borderWidth || 2) * this.scale
 
     return {
@@ -555,7 +537,6 @@ export default class CheckBox extends Base {
         type: 'modify',
         annotation: annotation
       })
-      this.getImage()
     }
   }
 
@@ -791,7 +772,6 @@ export default class CheckBox extends Base {
         rect
       }
     })
-    this.getImage()
   }
 
   update ({ start, end }) {
@@ -898,7 +878,6 @@ export default class CheckBox extends Base {
         type: 'modify',
         annotation: updateAnnot
       })
-      this.getImage()
     }
   }
 
@@ -975,7 +954,6 @@ export default class CheckBox extends Base {
       type: 'modify',
       annotation: updateAnnot
     })
-    this.getImage()
   }
 
   judgeCheckboxIsOne (name) {
@@ -999,44 +977,4 @@ export default class CheckBox extends Base {
     this.highlight = bool
     this.annotationContainer.style.backgroundColor = this.highlight ? '#4982E54D' : ''
   }
-
-  async getImage() {
-    const rect = this.initRect
-    const imgRect = {
-      width: parseInt(rect.width * this.layer.ratio + 1),
-      height: parseInt(rect.height * this.layer.ratio + 1)
-    }
-
-    const imageArray = await this.messageHandler.sendWithPromise('GetRenderAnnot', {
-      annotPtr: this.annotation.annotPtr,
-      rect: this.annotation.rect,
-      scale: this.scale * this.layer.ratio
-    })
-
-    const canvas = document.createElement('canvas')
-    canvas.style.width = imgRect.width + 'px'
-    canvas.style.height = imgRect.height + 'px'
-    canvas.width = imgRect.width
-    canvas.height = imgRect.height
-    let drawContext = canvas.getContext("2d")
-    drawContext.clearRect(0, 0, canvas.width, canvas.height)
-    let imageData = drawContext.createImageData(imgRect.width, imgRect.height)
-    imageData.data.set(imageArray)
-    drawContext.putImageData(imageData, 0, 0)
-    const imgSrc = canvas.toDataURL("image/png", 1)
-
-    if (this.imgEle) {
-      this.imgEle.src = imgSrc
-    } else {
-      let imgEle = document.createElement('img')
-      imgEle.style.width = '100%'
-      imgEle.style.height = '100%'
-      imgEle.style.pointerEvents = 'none'
-
-      imgEle.src = imgSrc
-      this.imgEle = imgEle
-
-      this.shapeElement.append(this.imgEle)
-    }
-  }
 }

+ 15 - 68
packages/core/src/form/combo_box.js

@@ -1,4 +1,5 @@
 import Base from '../annotation/base';
+import { MARGIN_DISTANCE } from '../../constants'
 import { getActualPoint, getClickPoint, createSvg, createElement } from '../annotation/utils';
 import { onClickOutsideUp } from '../ui_utils'
 
@@ -13,8 +14,7 @@ export default class ComboBox extends Base {
     eventBus,
     layer,
     show = false,
-    highlight,
-    messageHandler
+    highlight
   }) {
     super({
       container,
@@ -28,7 +28,6 @@ export default class ComboBox extends Base {
     })
 
     this.layer = layer
-    this.messageHandler = messageHandler
     this.hidden = true
     this.initial = false
     this.outline = null
@@ -57,7 +56,7 @@ export default class ComboBox extends Base {
     this.render()
   }
 
-  async render () {
+  render () {
     this.eventBus._on('setProperty', this.setProperty)
     this.eventBus._on('changeSelectAvailable', this.changeSelectAvailable)
     this.eventBus._on('setHighlightForm', this.setHighlight)
@@ -107,7 +106,7 @@ export default class ComboBox extends Base {
     this.annotationContainer = annotationContainer
     this.annotationContainer.addEventListener('mousedown', this.handleClick.bind(this))
 
-    let shapeElement = createElement(
+    let borderElement = createElement(
       'div',
       {
         left: 0,
@@ -118,18 +117,12 @@ export default class ComboBox extends Base {
         overflow: 'hidden'
       }
     )
-    this.shapeElement = shapeElement
-    
-    this.getImage()
-    this.annotationContainer.append(this.shapeElement)
-    this.container.append(this.annotationContainer)
+
+    this.borderElement = borderElement
 
     let selectElement = createElement(
       'select',
       {
-        position: 'absolute',
-        left: 0,
-        top: 0,
         paddingLeft: '4px',
         width: `${Math.abs(rect.width)}px`,
         height: `${Math.abs(rect.height)}px`,
@@ -146,8 +139,7 @@ export default class ComboBox extends Base {
         fontWeight: annotation.isBold ? 'bold' : 'normal',
         fontStyle: annotation.isItalic ? 'italic' : 'normal',
         textOverflow: 'ellipsis',
-        whiteSpace: 'nowrap',
-        opacity: 0
+        whiteSpace: 'nowrap'
       }
     )
     if (this.layer.toolMode === 'form') {
@@ -171,8 +163,7 @@ export default class ComboBox extends Base {
         right: '4px',
         top: '50%',
         transform: 'translateY(-50%)',
-        pointerEvents: 'none',
-        opacity: 0
+        pointerEvents: 'none'
       }
     )
     const path = createSvg(
@@ -188,8 +179,10 @@ export default class ComboBox extends Base {
     this.svgElement = svgElement
     this.svgElement.append(path)
     
-    this.shapeElement.append(this.svgElement)
-    this.shapeElement.append(this.selectElement)
+    this.borderElement.append(this.svgElement)
+    this.borderElement.append(this.selectElement)
+    this.annotationContainer.append(this.borderElement)
+    this.container.append(this.annotationContainer)
 
     // 添加选项
     if (annotation.items && annotation.items.length > 0) {
@@ -436,8 +429,7 @@ export default class ComboBox extends Base {
   };
 
   calculate (start, end) {
-    const initRect = this.rectCalc({ start, end })
-    this.initRect = initRect
+    const initRect = this.rectCalc({ start, end });
     const actualBdWidth = (this.annotation.borderWidth || 1) * this.scale
 
     return {
@@ -767,7 +759,6 @@ export default class ComboBox extends Base {
         rect
       }
     })
-    this.getImage()
   }
 
   update ({ start, end }) {
@@ -784,8 +775,8 @@ export default class ComboBox extends Base {
     this.annotationContainer.style.width = `${rect.width}px`;
     this.annotationContainer.style.height = `${rect.height}px`;
 
-    this.shapeElement.style.width = `${rect.width}px`;
-    this.shapeElement.style.height = `${rect.height}px`;
+    this.borderElement.style.width = `${rect.width}px`;
+    this.borderElement.style.height = `${rect.height}px`;
 
     this.selectElement.style.width = `${rect.width}px`;
     this.selectElement.style.height = `${rect.height}px`;
@@ -991,7 +982,6 @@ export default class ComboBox extends Base {
         } else {
           annotationData.fontName = fontArr[fontName].normal
         }
-        delete props.fontName
       }
 
       const updateAnnot = Object.assign({}, annotationData, props)
@@ -1001,7 +991,6 @@ export default class ComboBox extends Base {
         type: 'modify',
         annotation: updateAnnot
       })
-      this.getImage()
     }
   }
 
@@ -1063,7 +1052,6 @@ export default class ComboBox extends Base {
       } else {
         annotationData.fontName = fontArr[fontName].normal
       }
-      delete props.fontName
     }
 
     const updateAnnot = Object.assign({}, annotationData, props)
@@ -1071,7 +1059,6 @@ export default class ComboBox extends Base {
       type: 'modify',
       annotation: updateAnnot
     })
-    this.getImage()
   }
 
   changeSelectAvailable () {
@@ -1095,44 +1082,4 @@ export default class ComboBox extends Base {
     this.highlight = bool
     this.annotationContainer.style.backgroundColor = this.highlight ? '#4982E54D' : ''
   }
-
-  async getImage() {
-    const rect = this.initRect
-    const imgRect = {
-      width: parseInt(rect.width * this.layer.ratio + 1),
-      height: parseInt(rect.height * this.layer.ratio + 1)
-    }
-
-    const imageArray = await this.messageHandler.sendWithPromise('GetRenderAnnot', {
-      annotPtr: this.annotation.annotPtr,
-      rect: this.annotation.rect,
-      scale: this.scale * this.layer.ratio
-    })
-
-    const canvas = document.createElement('canvas')
-    canvas.style.width = imgRect.width + 'px'
-    canvas.style.height = imgRect.height + 'px'
-    canvas.width = imgRect.width
-    canvas.height = imgRect.height
-    let drawContext = canvas.getContext("2d")
-    drawContext.clearRect(0, 0, canvas.width, canvas.height)
-    let imageData = drawContext.createImageData(imgRect.width, imgRect.height)
-    imageData.data.set(imageArray)
-    drawContext.putImageData(imageData, 0, 0)
-    const imgSrc = canvas.toDataURL("image/png", 1)
-
-    if (this.imgEle) {
-      this.imgEle.src = imgSrc
-    } else {
-      let imgEle = document.createElement('img')
-      imgEle.style.width = '100%'
-      imgEle.style.height = '100%'
-      imgEle.style.pointerEvents = 'none'
-
-      imgEle.src = imgSrc
-      this.imgEle = imgEle
-
-      this.shapeElement.append(this.imgEle)
-    }
-  }
 }

+ 13 - 66
packages/core/src/form/list_box.js

@@ -13,8 +13,7 @@ export default class ListBox extends Base {
     eventBus,
     layer,
     show = false,
-    highlight,
-    messageHandler
+    highlight
   }) {
     super({
       container,
@@ -28,7 +27,6 @@ export default class ListBox extends Base {
     })
 
     this.layer = layer
-    this.messageHandler = messageHandler
     this.hidden = true
     this.initial = false
     this.outline = null
@@ -57,7 +55,7 @@ export default class ListBox extends Base {
     this.render()
   }
 
-  async render() {
+  render() {
     this.eventBus._on('setProperty', this.setProperty)
     this.eventBus._on('changeSelectAvailable', this.changeSelectAvailable)
     this.eventBus._on('setHighlightForm', this.setHighlight)
@@ -102,8 +100,8 @@ export default class ListBox extends Base {
     annotationContainer.style.backgroundColor = this.highlight ? '#4982E54D' : ''
     this.annotationContainer = annotationContainer
     this.annotationContainer.addEventListener('mousedown', this.handleClick.bind(this))
-    
-    let shapeElement = createElement(
+
+    let borderElement = createElement(
       'div',
       {
         left: 0,
@@ -113,18 +111,11 @@ export default class ListBox extends Base {
         position: 'relative'
       }
     )
-    this.shapeElement = shapeElement
-
-    this.getImage()
-    this.annotationContainer.append(this.shapeElement)
-    this.container.append(this.annotationContainer)
 
+    this.borderElement = borderElement
     let selectElement = createElement(
       'div',
       {
-        position: 'absolute',
-        left: 0,
-        top: 0,
         width: `${Math.abs(rect.width)}px`,
         height: `${Math.abs(rect.height)}px`,
         borderColor: annotation.borderColor,
@@ -137,12 +128,14 @@ export default class ListBox extends Base {
         fontStyle: annotation.isItalic ? 'italic' : 'normal',
         fontFamily: annotation.fontName,
         color: annotation.color || '#001A4E',
-        overflow: 'auto',
-        opacity: 0
+        overflow: 'auto'
       }
     )
     this.selectElement = selectElement
-    this.shapeElement.append(this.selectElement)
+
+    this.borderElement.append(this.selectElement)
+    this.annotationContainer.append(this.borderElement)
+    this.container.append(this.annotationContainer)
 
     // 添加选项
     if (annotation.items && annotation.items.length > 0) {
@@ -401,8 +394,7 @@ export default class ListBox extends Base {
   };
 
   calculate(start, end) {
-    const initRect = this.rectCalc({ start, end })
-    this.initRect = initRect
+    const initRect = this.rectCalc({ start, end });
     const actualBdWidth = (this.annotation.borderWidth || 1) * this.scale
 
     return {
@@ -743,7 +735,6 @@ export default class ListBox extends Base {
         rect
       }
     })
-    this.getImage()
   }
 
   update({ start, end }) {
@@ -760,8 +751,8 @@ export default class ListBox extends Base {
     this.annotationContainer.style.width = `${rect.width}px`;
     this.annotationContainer.style.height = `${rect.height}px`;
 
-    this.shapeElement.style.width = `${rect.width}px`;
-    this.shapeElement.style.height = `${rect.height}px`;
+    this.borderElement.style.width = `${rect.width}px`;
+    this.borderElement.style.height = `${rect.height}px`;
 
     this.selectElement.style.width = `${rect.width}px`;
     this.selectElement.style.height = `${rect.height}px`;
@@ -975,7 +966,6 @@ export default class ListBox extends Base {
         } else {
           annotationData.fontName = fontArr[fontName].normal
         }
-        delete props.fontName
       }
 
       const updateAnnot = Object.assign({}, annotationData, props)
@@ -985,7 +975,6 @@ export default class ListBox extends Base {
         type: 'modify',
         annotation: updateAnnot
       })
-      this.getImage()
     }
   }
 
@@ -1047,7 +1036,6 @@ export default class ListBox extends Base {
       } else {
         annotationData.fontName = fontArr[fontName].normal
       }
-      delete props.fontName
     }
 
     const updateAnnot = Object.assign({}, annotationData, props)
@@ -1055,7 +1043,6 @@ export default class ListBox extends Base {
       type: 'modify',
       annotation: updateAnnot
     })
-    this.getImage()
   }
 
   changeSelectAvailable() {
@@ -1083,44 +1070,4 @@ export default class ListBox extends Base {
     this.highlight = bool
     this.annotationContainer.style.backgroundColor = this.highlight ? '#4982E54D' : ''
   }
-
-  async getImage() {
-    const rect = this.initRect
-    const imgRect = {
-      width: parseInt(rect.width * this.layer.ratio + 1),
-      height: parseInt(rect.height * this.layer.ratio + 1)
-    }
-
-    const imageArray = await this.messageHandler.sendWithPromise('GetRenderAnnot', {
-      annotPtr: this.annotation.annotPtr,
-      rect: this.annotation.rect,
-      scale: this.scale * this.layer.ratio
-    })
-
-    const canvas = document.createElement('canvas')
-    canvas.style.width = imgRect.width + 'px'
-    canvas.style.height = imgRect.height + 'px'
-    canvas.width = imgRect.width
-    canvas.height = imgRect.height
-    let drawContext = canvas.getContext("2d")
-    drawContext.clearRect(0, 0, canvas.width, canvas.height)
-    let imageData = drawContext.createImageData(imgRect.width, imgRect.height)
-    imageData.data.set(imageArray)
-    drawContext.putImageData(imageData, 0, 0)
-    const imgSrc = canvas.toDataURL("image/png", 1)
-
-    if (this.imgEle) {
-      this.imgEle.src = imgSrc
-    } else {
-      let imgEle = document.createElement('img')
-      imgEle.style.width = '100%'
-      imgEle.style.height = '100%'
-      imgEle.style.pointerEvents = 'none'
-
-      imgEle.src = imgSrc
-      this.imgEle = imgEle
-
-      this.shapeElement.append(this.imgEle)
-    }
-  }
 }

+ 19 - 147
packages/core/src/form/push_button.js

@@ -13,8 +13,7 @@ export default class PushButton extends Base {
     eventBus,
     layer,
     show = false,
-    highlight,
-    messageHandler
+    highlight
   }) {
     super({
       container,
@@ -28,7 +27,6 @@ export default class PushButton extends Base {
     })
 
     this.layer = layer
-    this.messageHandler = messageHandler
     this.hidden = true
     this.initial = false
     this.outline = null
@@ -56,7 +54,7 @@ export default class PushButton extends Base {
     this.render()
   }
 
-  async render () {
+  render () {
     this.eventBus._on('setProperty', this.setProperty)
     this.eventBus._on('setHighlightForm', this.setHighlight)
 
@@ -106,18 +104,16 @@ export default class PushButton extends Base {
         position: 'relative'
       }
     )
+
     this.shapeElement = shapeElement
 
-    this.getImage()
     this.annotationContainer.append(this.shapeElement)
+
     this.container.append(this.annotationContainer)
 
     this.buttonContainer = createElement(
       'a',
       {
-        position: 'absolute',
-        left: 0,
-        top: 0,
         display: 'flex',
         alignItems: 'center',
         justifyContent: 'center',
@@ -134,13 +130,11 @@ export default class PushButton extends Base {
         fontWeight: annotation.isBold ? 'bold' : 'normal',
         fontStyle: annotation.isItalic ? 'italic' : 'normal',
         overflow: 'hidden',
-        textDecoration: 'none',
-        opacity: 0
+        textDecoration: 'none'
       }
     )
     this.buttonContainer.innerHTML = annotation.title
     this.shapeElement.append(this.buttonContainer)
-
     this.buttonContainer.addEventListener('blur', this.onBlur)
     if (this.annotation.url) {
       this.buttonContainer.setAttribute('href', this.annotation.url)
@@ -378,8 +372,7 @@ export default class PushButton extends Base {
   };
 
   calculate (start, end) {
-    const initRect = this.rectCalc({ start, end })
-    this.initRect = initRect
+    const initRect = this.rectCalc({ start, end });
     const actualbdwidth = (this.annotation.borderWidth || 2) * this.scale
 
     return {
@@ -707,7 +700,7 @@ export default class PushButton extends Base {
       top: start.y,
       right: end.x,
       bottom: end.y
-    }
+     }
 
     this.eventBus.dispatch('annotationChange', {
       type: 'modify',
@@ -720,7 +713,6 @@ export default class PushButton extends Base {
         rect
       }
     })
-    this.getImage()
   }
 
   update ({ start, end }) {
@@ -885,7 +877,6 @@ export default class PushButton extends Base {
         } else {
           annotationData.fontName = fontArr[fontName].normal
         }
-        delete props.fontName
       }
 
       const updateAnnot = Object.assign({}, annotationData, props)
@@ -893,32 +884,24 @@ export default class PushButton extends Base {
         type: 'modify',
         annotation: updateAnnot
       })
-      console.log(updateAnnot)
-      this.getImage()
     }
   }
 
   setProperty (props) {
     if (props.name !== this.annotation.name) return
-    const annotation = this.annotation
 
-    let updatePropsNum = 0
     for (const key in props) {
       for (const item in this.annotation) {
         if (item === key && this.annotation[item] !== props[key]) {
           this.annotation[item] = props[key]
-          updatePropsNum ++
-
+          
           if (key === 'backgroundColor') {
             this.buttonContainer.style[key] = props[key]
-            if (props[key] === '') {
-              props.clearBackgroundColor = true
-            }
           }
           if (key === 'fontSize') {
             this.buttonContainer.style.fontSize = props[key] + 'px'
           }
-          if (key === 'color') {
+          if (key === 'textColor') {
             this.buttonContainer.style.color = props[key]
           }
           if (key === 'fontName') {
@@ -931,136 +914,25 @@ export default class PushButton extends Base {
             this.buttonContainer.setAttribute('href', this.annotation.url)
             this.buttonContainer.setAttribute('target', '_blank')
           }
-          if (key === 'fontStyle') {
-            const fontStyle = props[key]
-            if (fontStyle === 'boldItalic') {
-              this.buttonContainer.style.fontStyle = 'italic'
-              this.buttonContainer.style.fontWeight = 'bold'
-              annotation.isBold = true
-              annotation.isItalic = true
-            } else if (fontStyle === 'bold') {
-              this.buttonContainer.style.fontStyle = 'normal'
-              this.buttonContainer.style.fontWeight = 'bold'
-              annotation.isBold = true
-              annotation.isItalic = false
-            } else if (fontStyle === 'italic') {
-              this.buttonContainer.style.fontStyle = 'italic'
-              this.buttonContainer.style.fontWeight = 'normal'
-              annotation.isBold = false
-              annotation.isItalic = true
-            } else {
-              annotation.isItalic = false
-              annotation.isBold = false
-              this.buttonContainer.style.fontStyle = 'normal'
-              this.buttonContainer.style.fontWeight = 'normal'
-            }
-          }
         }
       }
     }
 
-    if (updatePropsNum > 0) {
-      const annotationData = {
-        operate: "mod-form",
-        name: this.annotation.name,
-        pageIndex: this.page,
-        pagePtr: this.annotation.pagePtr,
-        annotPtr: this.annotation.annotPtr,
-        pageHeight: this.viewport.rawDims.pageHeight
-      }
-      if ((props.destPage || props.url) && this.annotation.actionType !== '0') {
-        annotationData.actionType = this.annotation.actionType
-      }
-
-      const isFont = ['fontSize', 'fontName', 'color', 'fontStyle'].some(item => props[item])
-      if (isFont) {
-        annotationData.fontSize = annotation.fontSize
-        annotationData.color = annotation.color
-        const fontArr = {
-          Courier: {
-            normal: 'Courier',
-            bold: 'Courier-Bold',
-            italic: 'Courier-Oblique',
-            boldItalic: 'Courier-BoldOblique'
-          },
-          Helvetica: {
-            normal: 'Helvetica',
-            bold: 'Helvetica-Bold',
-            italic: 'Helvetica-Oblique',
-            boldItalic: 'Helvetica-BoldOblique'
-          },
-          Times: {
-            normal: 'Times',
-            bold: 'Times-Bold',
-            italic: 'Times-Italic',
-            boldItalic: 'Times-BoldItalic'
-          }
-        }
-
-        const fontName = annotation.fontName
-        if (annotation.isBold && annotation.isItalic) {
-          annotationData.fontName = fontArr[fontName].boldItalic
-        } else if (annotation.isBold) {
-          annotationData.fontName = fontArr[fontName].bold
-        } else if (annotation.isItalic) {
-          annotationData.fontName = fontArr[fontName].italic
-        } else {
-          annotationData.fontName = fontArr[fontName].normal
-        }
-        delete props.fontName
-      }
-
-      const updateAnnot = Object.assign({}, annotationData, props)
-      this.eventBus.dispatch('annotationChange', {
-        type: 'modify',
-        annotation: updateAnnot
-      })
-      this.getImage()
+    const annotation = {
+      operate: "mod-form",
+      pageIndex: this.page,
+      pagePtr: this.annotation.pagePtr,
+      annotPtr: this.annotation.annotPtr,
     }
+    const updateAnnot = Object.assign({}, annotation, props)
+    this.eventBus.dispatch('annotationChange', {
+      type: 'modify',
+      annotation: updateAnnot
+    })
   }
 
   setHighlight (bool) {
     this.highlight = bool
     this.annotationContainer.style.backgroundColor = this.highlight ? '#4982E54D' : ''
   }
-
-  async getImage() {
-    const rect = this.initRect
-    const imgRect = {
-      width: parseInt(rect.width * this.layer.ratio + 1),
-      height: parseInt(rect.height * this.layer.ratio + 1)
-    }
-
-    const imageArray = await this.messageHandler.sendWithPromise('GetRenderAnnot', {
-      annotPtr: this.annotation.annotPtr,
-      rect: this.annotation.rect,
-      scale: this.scale * this.layer.ratio
-    })
-
-    const canvas = document.createElement('canvas')
-    canvas.style.width = imgRect.width + 'px'
-    canvas.style.height = imgRect.height + 'px'
-    canvas.width = imgRect.width
-    canvas.height = imgRect.height
-    let drawContext = canvas.getContext("2d")
-    drawContext.clearRect(0, 0, canvas.width, canvas.height)
-    let imageData = drawContext.createImageData(imgRect.width, imgRect.height)
-    imageData.data.set(imageArray)
-    drawContext.putImageData(imageData, 0, 0)
-    const imgSrc = canvas.toDataURL("image/png", 1)
-
-    if (this.imgEle) {
-      this.imgEle.src = imgSrc
-    } else {
-      let imgEle = document.createElement('img')
-      imgEle.style.width = '100%'
-      imgEle.style.height = '100%'
-      imgEle.style.pointerEvents = 'none'
-
-      imgEle.src = imgSrc
-      this.imgEle = imgEle
-
-      this.shapeElement.append(this.imgEle)
-    }
-  }
 }

+ 9 - 71
packages/core/src/form/radio_button.js

@@ -13,8 +13,7 @@ export default class RadioButton extends Base {
     eventBus,
     layer,
     show = false,
-    highlight,
-    messageHandler
+    highlight
   }) {
     super({
       container,
@@ -28,7 +27,6 @@ export default class RadioButton extends Base {
     })
 
     this.layer = layer
-    this.messageHandler = messageHandler
     this.hidden = true
     this.initial = false
     this.outline = null
@@ -56,7 +54,7 @@ export default class RadioButton extends Base {
     this.render()
   }
 
-  async render () {
+  render () {
     this.eventBus._on('setProperty', this.setProperty)
     this.eventBus._on('setHighlightForm', this.setHighlight)
 
@@ -86,28 +84,10 @@ export default class RadioButton extends Base {
     this.annotationContainer = annotationContainer
     this.annotationContainer.addEventListener('mousedown', this.handleClick.bind(this))
 
-    let shapeElement
-    shapeElement = createElement(
-      'div',
-      {
-        left: 0,
-        top: 0,
-        width: `${Math.abs(rect.width)}px`,
-        height: `${Math.abs(rect.height)}px`,
-        position: 'relative'
-      }
-    )
-    this.shapeElement = shapeElement
-
-    this.getImage()
-    this.annotationContainer.append(this.shapeElement)
-    this.container.append(this.annotationContainer)
-    
     let borderElement
     borderElement = createElement(
       'div',
       {
-        position: 'absolute',
         left: 0,
         top: 0,
         display: 'flex',
@@ -120,9 +100,10 @@ export default class RadioButton extends Base {
         borderStyle: annotation.borderStyle,
         borderRadius: '100%',
         backgroundColor: annotation.backgroundColor,
-        opacity: 0
+        position: 'relative'
       }
     )
+
     this.borderElement = borderElement
 
     // creat shape svg
@@ -139,6 +120,7 @@ export default class RadioButton extends Base {
         height: `${rect.height / 2}px`
       }
     )
+
     this.svgElement = svgElement
 
     // 填充的图形
@@ -206,7 +188,8 @@ export default class RadioButton extends Base {
     }
 
     this.borderElement.append(this.svgElement)
-    this.shapeElement.append(this.borderElement)
+    this.annotationContainer.append(this.borderElement)
+    this.container.append(this.annotationContainer)
 
     this.outerLineContainer = document.createElement('div')
     this.outerLineContainer.className = 'outline-container'
@@ -437,8 +420,7 @@ export default class RadioButton extends Base {
   };
 
   calculate (start, end) {
-    const initRect = this.rectCalc({ start, end })
-    this.initRect = initRect
+    const initRect = this.rectCalc({ start, end });
     const actualBdWidth = (this.annotation.borderWidth || 2) * this.scale
 
     return {
@@ -558,7 +540,6 @@ export default class RadioButton extends Base {
         type: 'modify',
         annotation: annotation
       })
-      this.getImage()
     }
   }
 
@@ -781,7 +762,7 @@ export default class RadioButton extends Base {
       top: start.y,
       right: end.x,
       bottom: end.y
-    }
+     }
 
     this.eventBus.dispatch('annotationChange', {
       type: 'modify',
@@ -794,7 +775,6 @@ export default class RadioButton extends Base {
         rect
       }
     })
-    this.getImage()
   }
 
   update ({ start, end }) {
@@ -899,7 +879,6 @@ export default class RadioButton extends Base {
         type: 'modify',
         annotation: updateAnnot
       })
-      this.getImage()
     }
   }
 
@@ -979,7 +958,6 @@ export default class RadioButton extends Base {
       type: 'modify',
       annotation: updateAnnot
     })
-    this.getImage()
   }
 
   cancelSameGroupButton () {
@@ -1016,44 +994,4 @@ export default class RadioButton extends Base {
     this.highlight = bool
     this.annotationContainer.style.backgroundColor = this.highlight ? '#4982E54D' : ''
   }
-
-  async getImage() {
-    const rect = this.initRect
-    const imgRect = {
-      width: parseInt(rect.width * this.layer.ratio + 1),
-      height: parseInt(rect.height * this.layer.ratio + 1)
-    }
-
-    const imageArray = await this.messageHandler.sendWithPromise('GetRenderAnnot', {
-      annotPtr: this.annotation.annotPtr,
-      rect: this.annotation.rect,
-      scale: this.scale * this.layer.ratio
-    })
-
-    const canvas = document.createElement('canvas')
-    canvas.style.width = imgRect.width + 'px'
-    canvas.style.height = imgRect.height + 'px'
-    canvas.width = imgRect.width
-    canvas.height = imgRect.height
-    let drawContext = canvas.getContext("2d")
-    drawContext.clearRect(0, 0, canvas.width, canvas.height)
-    let imageData = drawContext.createImageData(imgRect.width, imgRect.height)
-    imageData.data.set(imageArray)
-    drawContext.putImageData(imageData, 0, 0)
-    const imgSrc = canvas.toDataURL("image/png", 1)
-
-    if (this.imgEle) {
-      this.imgEle.src = imgSrc
-    } else {
-      let imgEle = document.createElement('img')
-      imgEle.style.width = '100%'
-      imgEle.style.height = '100%'
-      imgEle.style.pointerEvents = 'none'
-
-      imgEle.src = imgSrc
-      this.imgEle = imgEle
-
-      this.shapeElement.append(this.imgEle)
-    }
-  }
 }

+ 10 - 69
packages/core/src/form/text_field.js

@@ -14,8 +14,7 @@ export default class TextField extends Base {
     eventBus,
     layer,
     show = false,
-    highlight,
-    messageHandler
+    highlight
   }) {
     super({
       container,
@@ -29,7 +28,6 @@ export default class TextField extends Base {
     })
 
     this.layer = layer
-    this.messageHandler = messageHandler
     this.hidden = true
     this.initial = false
     this.outline = null
@@ -114,10 +112,11 @@ export default class TextField extends Base {
         position: 'relative'
       }
     )
+
     this.shapeElement = shapeElement
 
-    this.getImage()
     this.annotationContainer.append(this.shapeElement)
+
     this.container.append(this.annotationContainer)
 
     // create text
@@ -354,8 +353,7 @@ export default class TextField extends Base {
   };
 
   calculate (start, end) {
-    const initRect = this.rectCalc({ start, end })
-    this.initRect = initRect
+    const initRect = this.rectCalc({ start, end });
     const actualBdWidth = (this.annotation.borderWidth || 1) * this.scale
 
     return {
@@ -462,8 +460,6 @@ export default class TextField extends Base {
       }, 0);
       this.textContainer.style.pointerEvents = 'auto'
       this.textContainer.style.cursor = 'text'
-      this.textContainer.style.opacity = ''
-      this.imgEle.style.opacity = 0
     }
   }
 
@@ -487,7 +483,7 @@ export default class TextField extends Base {
     this.eventBus._off('textfieldPropertyPanelChanged', this.handlePropertyPanel)
   }
 
-  async handleBlur () {
+  handleBlur () {
     if (this.annotation.contents !== this.textContainer.value) {
       this.annotation.contents = this.textContainer.value
       this.eventBus.dispatch('annotationChange', {
@@ -502,12 +498,9 @@ export default class TextField extends Base {
           contents: this.annotation.contents
         }
       })
-      this.getImage()
     }
     this.textContainer.style.pointerEvents = 'none'
     this.textContainer.style.cursor = 'pointer'
-    this.textContainer.style.opacity = 0
-    this.imgEle.style.opacity = ''
   }
 
   handleMouseDown (event) {
@@ -712,7 +705,7 @@ export default class TextField extends Base {
       top: start.y,
       right: end.x,
       bottom: end.y
-    }
+     }
 
     this.eventBus.dispatch('annotationChange', {
       type: 'modify',
@@ -890,7 +883,6 @@ export default class TextField extends Base {
         } else {
           annotationData.fontName = fontArr[fontName].normal
         }
-        delete props.fontName
       }
 
       const updateAnnot = Object.assign({}, annotationData, props)
@@ -898,7 +890,6 @@ export default class TextField extends Base {
         type: 'modify',
         annotation: updateAnnot
       })
-      this.getImage()
     }
   }
 
@@ -923,10 +914,7 @@ export default class TextField extends Base {
           width: '100%',
           height: '100%',
           outline: 'none',
-          borderColor: this.annotation.borderColor,
-          borderStyle: this.annotation.borderStyle,
-          borderWidth: this.annotation.borderWidth + 'px',
-          borderRadius: 0,
+          border: 'none',
           color: this.annotation.color,
           backgroundColor: this.annotation.backgroundColor,
           pointerEvents: 'none',
@@ -937,8 +925,7 @@ export default class TextField extends Base {
           fontSize: this.annotation.fontSize + 'px',
           fontWeight: this.annotation.isBold ? 'bold' : 'normal',
           fontStyle: this.annotation.isItalic ? 'italic' : 'normal',
-          fontFamily: this.annotation.fontName,
-          opacity: 0
+          fontFamily: this.annotation.fontName
         }
       )
       textContainer.innerHTML = this.annotation.contents
@@ -952,10 +939,7 @@ export default class TextField extends Base {
           width: '100%',
           height: '100%',
           outline: 'none',
-          borderColor: this.annotation.borderColor,
-          borderStyle: this.annotation.borderStyle,
-          borderWidth: this.annotation.borderWidth + 'px',
-          borderRadius: 0,
+          border: 'none',
           color: this.annotation.color,
           backgroundColor: this.annotation.backgroundColor,
           pointerEvents: 'none',
@@ -964,8 +948,7 @@ export default class TextField extends Base {
           fontSize: this.annotation.fontSize + 'px',
           fontWeight: this.annotation.isBold ? 'bold' : 'normal',
           fontStyle: this.annotation.isItalic ? 'italic' : 'normal',
-          fontFamily: this.annotation.fontName,
-          opacity: 0
+          fontFamily: this.annotation.fontName
         },
         { value: this.annotation.contents }
       )
@@ -1096,7 +1079,6 @@ export default class TextField extends Base {
       } else {
         annotationData.fontName = fontArr[fontName].normal
       }
-      delete props.fontName
     }
 
     const updateAnnot = Object.assign({}, annotationData, props)
@@ -1104,51 +1086,10 @@ export default class TextField extends Base {
       type: 'modify',
       annotation: updateAnnot
     })
-    this.getImage()
   }
 
   setHighlight (bool) {
     this.highlight = bool
     this.annotationContainer.style.backgroundColor = this.highlight ? '#4982E54D' : ''
   }
-
-  async getImage() {
-    const rect = this.initRect
-    const imgRect = {
-      width: parseInt(rect.width * this.layer.ratio + 1),
-      height: parseInt(rect.height * this.layer.ratio + 1)
-    }
-
-    const imageArray = await this.messageHandler.sendWithPromise('GetRenderAnnot', {
-      annotPtr: this.annotation.annotPtr,
-      rect: this.annotation.rect,
-      scale: this.scale * this.layer.ratio
-    })
-
-    const canvas = document.createElement('canvas')
-    canvas.style.width = imgRect.width + 'px'
-    canvas.style.height = imgRect.height + 'px'
-    canvas.width = imgRect.width
-    canvas.height = imgRect.height
-    let drawContext = canvas.getContext("2d")
-    drawContext.clearRect(0, 0, canvas.width, canvas.height)
-    let imageData = drawContext.createImageData(imgRect.width, imgRect.height)
-    imageData.data.set(imageArray)
-    drawContext.putImageData(imageData, 0, 0)
-    const imgSrc = canvas.toDataURL("image/png", 1)
-
-    if (this.imgEle) {
-      this.imgEle.src = imgSrc
-    } else {
-      let imgEle = document.createElement('img')
-      imgEle.style.width = '100%'
-      imgEle.style.height = '100%'
-      imgEle.style.pointerEvents = 'none'
-
-      imgEle.src = imgSrc
-      this.imgEle = imgEle
-
-      this.shapeElement.append(this.imgEle)
-    }
-  }
 }

+ 8 - 8
packages/core/src/index.js

@@ -293,18 +293,18 @@ class ComPDFKitViewer {
       if (!this.webviewerServer && this.enableCustomFont) {
         const webFontURL = this.webFontURL
 
-        const response = await fetch(webFontURL + 'font.ff')
-        if (response.ok) {
-          const resData = await response.arrayBuffer()
-          this.#fileList = new Uint8Array(resData)
+        const fileData = await fetch(webFontURL + 'fonts.json')
+        if (fileData.ok) {
+          this.fontsJson = await fileData.json()
         } else {
           console.error('Invalid webFontURL')
         }
 
-        if (this.#fileList) {
-          const fileData = await fetch(webFontURL + 'fonts.json')
-          if (fileData.ok) {
-            this.fontsJson = await fileData.json()
+        if (this.fontsJson && this.fontsJson[0].filePath && this.fontsJson[0].filePath.endsWith('brotli')) {
+          const response = await fetch(webFontURL + 'font.ff')
+          if (response.ok) {
+            const resData = await response.arrayBuffer()
+            this.#fileList = new Uint8Array(resData)
           } else {
             console.error('Invalid webFontURL')
           }

+ 1 - 1
packages/core/src/markup/text_annotation.js

@@ -150,7 +150,7 @@ class TextAnnotation extends BaseAnnotation {
     this.deletetButton = deletetButton
     this.outerLineContainer.append(rectContainer)
     this.outerLineContainer.append(deletetButton)
-    this.outerLineContainer.append(this.replyButton)
+    this.enableReply && this.outerLineContainer.append(this.replyButton)
   }
 
   getActualRect (viewport, s) {

+ 20 - 21
packages/core/src/worker/compdfkit_worker.js

@@ -10,7 +10,7 @@ let ComPDFKitJS = {
   ComPDFKitDownloadFont,
   ComPDFKitDownloadFontA,
   FontNameList: [],
-  FontCount: 120,
+  FontCount: 1,
   opened_image: [],
   opened_files: [],
   opened_cert: [],
@@ -73,18 +73,12 @@ function readFileAsync(url) {
 }
 
 function ComPDFKitDownloadFont(index){
-  if (index === 0) {
-    return  ComPDFKitJS.opened_Font[index];
-  }
   if (ComPDFKitJS.opened_Font[index]) {
     return ComPDFKitJS.opened_Font[index]
   }
   return fontFile
 }
 function ComPDFKitDownloadFontA(index){
-  if (index === 0) {
-    return  ComPDFKitJS.opened_Font[index];
-  }
   if (ComPDFKitJS.opened_Font[index]) {
     return ComPDFKitJS.opened_Font[index]
   }
@@ -160,13 +154,22 @@ class CPDFWorker {
 
       if (data.fileList) {
         ComPDFKitJS.opened_Font[0] = data.fileList
+      }
 
-        if (data.webFontURL !== 'https://www.compdf.com/fonts/') {
-          webFontURL = data.webFontURL
-        }
+      if (data.webFontURL !== 'https://www.compdf.com/fonts/') {
+        webFontURL = data.webFontURL
+      }
+
+      if (data.fontsJson) {
         fontsJson = data.fontsJson
 
-        Module._InitComPDFkitFont()
+        const compress = !!ComPDFKitJS.opened_Font[0]
+        ComPDFKitJS.FontCount = (compress ? (data.fontsJson.length + 1) : data.fontsJson.length)
+        if (!compress && data.fontsJson.length === 1) {
+          const fontFile = readFileAsync(webFontURL + data.fontsJson[0].filePath)
+          ComPDFKitJS.opened_Font[0] = fontFile
+        }
+        Module._InitComPDFkitFont(compress)
       }
 
       if (data.enableDefaultFont && !ComPDFKitJS.opened_DefFont[0]) {
@@ -406,7 +409,7 @@ class CPDFWorker {
 
       DataArray = []
 
-      const embedded = !!fontsJson || ComPDFKitJS.opened_DefFont[0]
+      const embedded = !!fontsJson || !!ComPDFKitJS.opened_DefFont[0]
       Module._SaveDocumentByStream(doc, 2, embedded)
 
       const addResult = Module._AddSignSaveDocument(doc, signaturePtr, certPtr)
@@ -623,16 +626,14 @@ class CPDFWorker {
         const textAlignmentInt = ALIGNMAP[textAlignment.toUpperCase()]
         Module._SetWidgetTextJustification(annotPtr, textAlignmentInt)
       }
-      if (annotation.hasOwnProperty('isMultiLine')) {
+      if (annotation.isMultiLine) {
         const { annotPtr, isMultiLine } = annotation
         Module._SetMultiLine(annotPtr, isMultiLine)
       }
       if (annotation.author) {
         setAnnotAuthor(annotation)
       }
-
-      if (annotation.operate === 'mod-form') Module._UpdateFormAp(annotation.annotPtr)
-      else Module._UpdateAnnotAp(annotation.annotPtr, 0)
+      Module._UpdateAnnotAp(annotation.annotPtr, 0)
     })
 
     messageHandler.on('FlattenPage', (data) => {
@@ -2232,9 +2233,7 @@ function createAnnotation(doc, pagePtr, annotation) {
     })
   }
 
-  if (annotation.operate === 'mod-form') Module._UpdateFormAp(annotation.annotPtr)
-  else Module._UpdateAnnotAp(annotation.annotPtr, 0)
-
+  Module._UpdateAnnotAp(annotPtr, 0)
   return {
     annotPtr
   }
@@ -3076,7 +3075,7 @@ function addToTrustedCertificates(data) {
 async function copyDocument(doc, password) {
   DataArray = []
 
-  const embedded = !!fontsJson || ComPDFKitJS.opened_DefFont[0]
+  const embedded = !!fontsJson || !!ComPDFKitJS.opened_DefFont[0]
   Module._SaveDocumentByStream(doc, 2, embedded);
   let pdfData = []
   for (let i = 0; i < DataArray.length; i++) {
@@ -3101,7 +3100,7 @@ function saveDocument(doc, saveType) {
   DataArray = []
   saveType === 1 && DataArray.push(ComPDFKitJS.opened_files[0])
 
-  const embedded = !!fontsJson || ComPDFKitJS.opened_DefFont[0]
+  const embedded = !!fontsJson || !!ComPDFKitJS.opened_DefFont[0]
   Module._SaveDocumentByStream(doc, saveType, embedded)
   let pdfData = []
   for (let i = 0; i < DataArray.length; i++) {

+ 1 - 1
packages/webview/src/components/RightPanel/RightPanel.vue

@@ -377,7 +377,7 @@
   })
   
   watch(() => property.isChecked, (newValue, oldValue) => {
-    useDocument.setPropertyPanel({'isChecked': +newValue})
+    useDocument.setPropertyPanel({'isChecked': newValue})
   })
   
   watch(() => property.actionType, (newValue, oldValue) => {

+ 2 - 2
packages/webview/src/helpers/utils.js

@@ -42,8 +42,6 @@ const hslToRgb = (h, s, l) => {
 
 // 转换颜色 hsl / hex -> rgb
 const convertColor = (colorStr) => {
-  if (!colorStr) return null;
-
   if (colorStr.startsWith('#')) {
     const hexValues = colorStr.slice(1).match(/.{2}/g);
     if (hexValues) {
@@ -74,6 +72,8 @@ const convertColor = (colorStr) => {
       return {R, G, B};
     }
   }
+
+  return null;
 }
 
 // 判断两个颜色字符串在阈值外是否相同