|
@@ -47,6 +47,7 @@ let DiffInfoArray = []
|
|
let AnnotArray = []
|
|
let AnnotArray = []
|
|
let fontsJson = null
|
|
let fontsJson = null
|
|
let fontFile = null
|
|
let fontFile = null
|
|
|
|
+let webFontURL = './fonts/'
|
|
|
|
|
|
import MessageHandler from "../message_handler"
|
|
import MessageHandler from "../message_handler"
|
|
import { convertFileToBuffer, convertBase64ToBytes } from '../fileHandler';
|
|
import { convertFileToBuffer, convertBase64ToBytes } from '../fileHandler';
|
|
@@ -67,9 +68,6 @@ function readFileAsync(url) {
|
|
if (xhr.status == 200 || xhr.status == 206) {
|
|
if (xhr.status == 200 || xhr.status == 206) {
|
|
const responseArray = new Uint8Array(xhr.response)
|
|
const responseArray = new Uint8Array(xhr.response)
|
|
return responseArray
|
|
return responseArray
|
|
- }
|
|
|
|
- xhr.onreadystatechange = function () {
|
|
|
|
-
|
|
|
|
}
|
|
}
|
|
return 0
|
|
return 0
|
|
}
|
|
}
|
|
@@ -78,15 +76,22 @@ function ComPDFKitDownloadFont(index){
|
|
if (index === 0) {
|
|
if (index === 0) {
|
|
return ComPDFKitJS.opened_Font[index];
|
|
return ComPDFKitJS.opened_Font[index];
|
|
}
|
|
}
|
|
|
|
+ if (ComPDFKitJS.opened_Font[index]) {
|
|
|
|
+ return ComPDFKitJS.opened_Font[index]
|
|
|
|
+ }
|
|
return fontFile
|
|
return fontFile
|
|
}
|
|
}
|
|
function ComPDFKitDownloadFontA(index){
|
|
function ComPDFKitDownloadFontA(index){
|
|
if (index === 0) {
|
|
if (index === 0) {
|
|
return ComPDFKitJS.opened_Font[index];
|
|
return ComPDFKitJS.opened_Font[index];
|
|
}
|
|
}
|
|
|
|
+ if (ComPDFKitJS.opened_Font[index]) {
|
|
|
|
+ return ComPDFKitJS.opened_Font[index]
|
|
|
|
+ }
|
|
const font = fontsJson[index - 1]
|
|
const font = fontsJson[index - 1]
|
|
- fontFile = readFileAsync('./fonts/' + font.filePath)
|
|
|
|
|
|
+ fontFile = readFileAsync(webFontURL + font.filePath)
|
|
CPDFWorker.MessageHandler.send('LoadFont', { fontFamily: font.family })
|
|
CPDFWorker.MessageHandler.send('LoadFont', { fontFamily: font.family })
|
|
|
|
+ ComPDFKitJS.opened_Font[index] = fontFile
|
|
return fontFile
|
|
return fontFile
|
|
}
|
|
}
|
|
|
|
|
|
@@ -160,9 +165,15 @@ class CPDFWorker {
|
|
if (data.defaultFont) {
|
|
if (data.defaultFont) {
|
|
ComPDFKitJS.opened_DefFont[0] = data.defaultFont
|
|
ComPDFKitJS.opened_DefFont[0] = data.defaultFont
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+ if (data.webFontURL !== './lib/fonts/') {
|
|
|
|
+ webFontURL = data.webFontURL
|
|
|
|
+ }
|
|
fontsJson = data.fontsJson
|
|
fontsJson = data.fontsJson
|
|
|
|
|
|
|
|
+ if (data.notoSansFont) {
|
|
|
|
+ ComPDFKitJS.opened_Font[1] = data.notoSansFont
|
|
|
|
+ }
|
|
|
|
+
|
|
Module._InitComPDFkitFont()
|
|
Module._InitComPDFkitFont()
|
|
const doc = Module._InitDocument()
|
|
const doc = Module._InitDocument()
|
|
|
|
|
|
@@ -418,9 +429,6 @@ class CPDFWorker {
|
|
const newDoc = Module._InitDocument()
|
|
const newDoc = Module._InitDocument()
|
|
const passwordPtr = stringToNewUTF8('')
|
|
const passwordPtr = stringToNewUTF8('')
|
|
Module._LoadDocumentByStream(newDoc, length, buffer.length, passwordPtr)
|
|
Module._LoadDocumentByStream(newDoc, length, buffer.length, passwordPtr)
|
|
-
|
|
|
|
- // const modifyResult = Module._AddSignModifyDocument(signaturePtr, res, 1, ComPDFKitJS.opened_files[1].length)
|
|
|
|
- // console.log(modifyResult)
|
|
|
|
})
|
|
})
|
|
|
|
|
|
messageHandler.on('LoadCertificates', async (data) => {
|
|
messageHandler.on('LoadCertificates', async (data) => {
|