You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
import { jsPDF } from "jspdf"
var font = 'AAEAAAAQAQ...';
var callAddFont = function () {
this.addFileToVFS('googlesansmedium-normal.ttf', font);
this.addFont('googlesansmedium-normal.ttf', 'googlesansmedium', 'normal');
};
jsPDF.API.events.push(['addFonts', callAddFont])
报错:
Uncaught SyntaxError: Cannot use import statement outside a module (at googlesansmedium-normal.js:1:1)
PendingScript
(anonymous) @ index.common.js:219
checkFont @ index.common.js:213
(anonymous) @ index.common.js:197
exportPDF @ index.common.js:196
handleExportEvent @ index.common.js:234
preventEvent @ table.js:9365
(anonymous) @ hook.js:763
handleExport @ hook.js:756
exportData @ hook.js:1348
exportEvent @ export-panel.js:122
confirmEvent @ export-panel.js:139
callWithErrorHandling @ runtime-core.esm-bundler.js:199
callWithAsyncErrorHandling @ runtime-core.esm-bundler.js:206
emit @ runtime-core.esm-bundler.js:4380
(anonymous) @ runtime-core.esm-bundler.js:8232
dispatchEvent @ button.js:485
clickEvent @ button.js:273
callWithErrorHandling @ runtime-core.esm-bundler.js:199
callWithAsyncErrorHandling @ runtime-core.esm-bundler.js:206
invoker @ runtime-dom.esm-bundler.js:730
console.js:22 jsPDF PubSub Error Failed to execute 'atob' on 'Window': The string to be decoded is not correctly encoded. InvalidCharacterError: Failed to execute 'atob' on 'Window': The string to be decoded is not correctly encoded.
at ttfsupport.js:31:39
at Object.<anonymous> (ttfsupport.js:39:33)
at C.publish (jspdf.js:70:18)
at Object.pe2 (jspdf.js:2449:12)
at E.y2.addFont (jspdf.js:4970:20)
at exportMethod2 (index.common.js:139:13)
at index.common.js:200:19
error @ console.js:22
C.publish @ jspdf.js:73
pe2 @ jspdf.js:2449
E.y2.addFont @ jspdf.js:4970
exportMethod2 @ index.common.js:139
(anonymous) @ index.common.js:200
setTimeout
(anonymous) @ index.common.js:199
Promise.then
(anonymous) @ index.common.js:197
exportPDF @ index.common.js:196
handleExportEvent @ index.common.js:234
preventEvent @ table.js:9365
(anonymous) @ hook.js:763
handleExport @ hook.js:756
exportData @ hook.js:1348
exportEvent @ export-panel.js:122
confirmEvent @ export-panel.js:139
callWithErrorHandling @ runtime-core.esm-bundler.js:199
callWithAsyncErrorHandling @ runtime-core.esm-bundler.js:206
emit @ runtime-core.esm-bundler.js:4380
(anonymous) @ runtime-core.esm-bundler.js:8232
dispatchEvent @ button.js:485
clickEvent @ button.js:273
callWithErrorHandling @ runtime-core.esm-bundler.js:199
callWithAsyncErrorHandling @ runtime-core.esm-bundler.js:206
invoker @ runtime-dom.esm-bundler.js:730
split_text_to_size.js:56 Uncaught TypeError: Cannot read properties of undefined (reading 'widths')
at Ht.getCharWidthsArray (split_text_to_size.js:56:37)
at Ht.getStringUnitWidth (split_text_to_size.js:137:10)
at t2.getTextWidth (annotations.js:401:13)
at exportMethod2 (index.common.js:160:27)
at index.common.js:200:19
umd:
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? factory(require('jspdf')) :
typeof define === 'function' && define.amd ? define(['jspdf'], factory) :
(global = global || self, factory(global.jspdf));
}(this, (function (jspdf) { 'use strict';
var jsPDF = jspdf.jsPDF;
var font = 'AAEAAAAQAQAABAA...';
var callAddFont = function () {
this.addFileToVFS('googlesansmedium-normal.ttf', font);
this.addFont('googlesansmedium-normal.ttf', 'googlesansmedium', 'normal');
};
jsPDF.API.events.push(['addFonts', callAddFont])
报错:
Uncaught TypeError: Cannot read properties of undefined (reading 'jsPDF')
at googlesansmedium-normal.js:6:19
at googlesansmedium-normal.js:4:31
at googlesansmedium-normal.js:5:2
(anonymous) @ googlesansmedium-normal.js:6
(anonymous) @ googlesansmedium-normal.js:4
(anonymous) @ googlesansmedium-normal.js:5
PendingScript
(anonymous) @ index.common.js:219
checkFont @ index.common.js:213
(anonymous) @ index.common.js:197
exportPDF @ index.common.js:196
handleExportEvent @ index.common.js:234
preventEvent @ table.js:9365
(anonymous) @ hook.js:763
handleExport @ hook.js:756
exportData @ hook.js:1348
exportEvent @ export-panel.js:122
confirmEvent @ export-panel.js:139
callWithErrorHandling @ runtime-core.esm-bundler.js:199
callWithAsyncErrorHandling @ runtime-core.esm-bundler.js:206
emit @ runtime-core.esm-bundler.js:4380
(anonymous) @ runtime-core.esm-bundler.js:8232
dispatchEvent @ button.js:485
clickEvent @ button.js:273
callWithErrorHandling @ runtime-core.esm-bundler.js:199
callWithAsyncErrorHandling @ runtime-core.esm-bundler.js:206
invoker @ runtime-dom.esm-bundler.js:730
console.js:22 jsPDF PubSub Error Failed to execute 'atob' on 'Window': The string to be decoded is not correctly encoded. InvalidCharacterError: Failed to execute 'atob' on 'Window': The string to be decoded is not correctly encoded.
at ttfsupport.js:31:39
at Object.<anonymous> (ttfsupport.js:39:33)
at C.publish (jspdf.js:70:18)
at Object.pe2 (jspdf.js:2449:12)
at E.y2.addFont (jspdf.js:4970:20)
at exportMethod2 (index.common.js:139:13)
at index.common.js:200:19
error @ console.js:22
C.publish @ jspdf.js:73
pe2 @ jspdf.js:2449
E.y2.addFont @ jspdf.js:4970
exportMethod2 @ index.common.js:139
(anonymous) @ index.common.js:200
setTimeout
(anonymous) @ index.common.js:199
Promise.then
(anonymous) @ index.common.js:197
exportPDF @ index.common.js:196
handleExportEvent @ index.common.js:234
preventEvent @ table.js:9365
(anonymous) @ hook.js:763
handleExport @ hook.js:756
exportData @ hook.js:1348
exportEvent @ export-panel.js:122
confirmEvent @ export-panel.js:139
callWithErrorHandling @ runtime-core.esm-bundler.js:199
callWithAsyncErrorHandling @ runtime-core.esm-bundler.js:206
emit @ runtime-core.esm-bundler.js:4380
(anonymous) @ runtime-core.esm-bundler.js:8232
dispatchEvent @ button.js:485
clickEvent @ button.js:273
callWithErrorHandling @ runtime-core.esm-bundler.js:199
callWithAsyncErrorHandling @ runtime-core.esm-bundler.js:206
invoker @ runtime-dom.esm-bundler.js:730
split_text_to_size.js:56 Uncaught TypeError: Cannot read properties of undefined (reading 'widths')
at Ht.getCharWidthsArray (split_text_to_size.js:56:37)
at Ht.getStringUnitWidth (split_text_to_size.js:137:10)
at t2.getTextWidth (annotations.js:401:13)
at exportMethod2 (index.common.js:160:27)
at index.common.js:200:19
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
-
googlesansmedium-normal.js使用jspdf提供的转换工具转换的,到处是一直报错。
es module:
报错:
umd:
报错:
Beta Was this translation helpful? Give feedback.
All reactions