|
@@ -141,7 +141,7 @@ class CPDFWorker {
|
|
|
|
|
|
messageHandler.on('GetAnnotLink', (data) => {
|
|
|
const { pagePtr, annotPtr } = data
|
|
|
-
|
|
|
+
|
|
|
Rect = {}
|
|
|
Module._GetAnnotRect(pagePtr, annotPtr)
|
|
|
const rect = {
|
|
@@ -154,7 +154,8 @@ class CPDFWorker {
|
|
|
const rawContent = Module._GetAnnotContent(annotPtr)
|
|
|
const content = UTF8ToString(rawContent)
|
|
|
const rawCreateDate = Module._GetAnnotCreationDate(annotPtr)
|
|
|
- const createDate = parseAdobePDFTimestamp(UTF8ToString(rawCreateDate))
|
|
|
+ const date = UTF8ToString(rawCreateDate)
|
|
|
+ const createDate = date && parseAdobePDFTimestamp(date)
|
|
|
|
|
|
FontDa = {}
|
|
|
Module._GetAnnotFont(annotPtr)
|
|
@@ -279,7 +280,8 @@ class CPDFWorker {
|
|
|
|
|
|
RGBColor = {}
|
|
|
const fillColor = {}
|
|
|
- Module._GetAnnotFilledRGBColor(annotPtr)
|
|
|
+ const isFilled = Module._GetAnnotFilledRGBColor(annotPtr)
|
|
|
+ console.log(isFilled)
|
|
|
for (key in RGBColor) {
|
|
|
fillColor[key] = roundToDecimalPlaces(RGBColor[key] * 255)
|
|
|
}
|
|
@@ -641,6 +643,12 @@ class CPDFWorker {
|
|
|
return createAnnotation(doc, pagePtr, annotation)
|
|
|
})
|
|
|
|
|
|
+ messageHandler.on('XFDFExportAnnotations', (data) => {
|
|
|
+ const { doc } = data
|
|
|
+ const xfdfStream = exportXFDFByStream(doc)
|
|
|
+ return xfdfStream.Content
|
|
|
+ })
|
|
|
+
|
|
|
messageHandler.on('SaveDocumentByStream', (data) => {
|
|
|
console.log('SaveDocumentByStream')
|
|
|
const { doc } = data
|
|
@@ -699,27 +707,31 @@ function createAnnotation(doc, pagePtr, annotation) {
|
|
|
|
|
|
switch (typeInt) {
|
|
|
case AnnotationType.HIGHLIGHT:
|
|
|
+ console.log(typeInt, annotation)
|
|
|
const createColorResult = Module._SetAnnotRGBColor(annotPtr, 1, 0, 0)
|
|
|
+ Module._SetAnnotTransparency(annotPtr, 1)
|
|
|
console.log(createColorResult)
|
|
|
-
|
|
|
+
|
|
|
const createContentReslut = Module._SetAnnotContent(annotPtr, stringToNewUTF8(annotation.content))
|
|
|
console.log(createContentReslut)
|
|
|
const { quadPointsX, quadPointsY } = annotation
|
|
|
+
|
|
|
const length = quadPointsX.length
|
|
|
let pointXBytes = length * 4
|
|
|
let pointXPtr = _malloc(pointXBytes)
|
|
|
for (var i = 0; i < length; i++) {
|
|
|
- Module.HEAP32[pointXPtr / 4 + i] = 0
|
|
|
+ Module.HEAPF32[pointXPtr / 4 + i] = quadPointsX[i]
|
|
|
}
|
|
|
|
|
|
let pointYBytes = length * 4
|
|
|
let pointYPtr = _malloc(pointYBytes)
|
|
|
for (var i = 0; i < length; i++) {
|
|
|
- Module.HEAP32[pointYPtr / 4 + i] = 0
|
|
|
+ Module.HEAPF32[pointYPtr / 4 + i] = quadPointsY[i]
|
|
|
}
|
|
|
|
|
|
const createQuadResult = Module._SetQuadPoints(pagePtr, annotPtr, pointXPtr, pointYPtr, length)
|
|
|
- console.log(createQuadResult)
|
|
|
+ const update = Module._UpdateAnnotAp(annotPtr, 0)
|
|
|
+ console.log(update)
|
|
|
break
|
|
|
case AnnotationType.TEXT:
|
|
|
case AnnotationType.LINK:
|
|
@@ -763,6 +775,14 @@ function saveDocumentByStream(doc) {
|
|
|
return pdfData
|
|
|
}
|
|
|
|
|
|
+function exportXFDFByStream(doc) {
|
|
|
+ XFDFData={}
|
|
|
+ console.log(doc)
|
|
|
+ Module._XFDFExportAnnotations(doc)
|
|
|
+ return XFDFData
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
function setAnnotRect(data) {
|
|
|
const { pagePtr, annotPtr, rect } = data
|
|
|
const { left, right, bottom, top } = rect
|