将 Zapfdingbats 与 jsPDf 结合使用
Using Zapfdingbats with jsPDf
我正在尝试使用 jsPDf 和内置的 Zapfdingbats 字体将复选标记作为文本添加到 pdf 文档,但我 运行 遇到了问题。访问此字体中字形的正确方法是什么?
doc.setFont("Zapfdingbats");
doc.setFontStyle("normal");
doc.text("\u2714", 20, 20, null, null, "left");
当我使用上述方法并在 iframe 中呈现 pdf 时,我通过警告消息收到错误消息 "Error in function Object.F (http://localhost:3000/static/js/1.chunk.js:26266:81): Failed to execute 'btoa' on 'Window': The string to be encoded contains characters outside of the Latin1 range."
注意:我正在使用 create-react-app 在我的 React 应用程序中使用它。
当我尝试时:
doc.text(btoa(unescape(encodeURIComponent("\u2714"))), 20, 20, null, null, "left");
我得到了复选标记,但还有三个我不想要的附加符号。
复选标记字形映射到“4”
doc.text("4", xPosition, yPosition, null, null, "left");
关于答案的问题:你怎么知道复选标记映射到“4”?我正在尝试使用 Symbol 字体中的商标 (TM),但还没有弄清楚该怎么做。
我能够使用上面的答案在我想要 TM 的地方打勾。如果我能找到 Symbol 字体的正确映射,它应该可以工作。 (我试过“\u2122”,但它在文件中的结果就像 py!)
我正在尝试使用 jsPDf 和内置的 Zapfdingbats 字体将复选标记作为文本添加到 pdf 文档,但我 运行 遇到了问题。访问此字体中字形的正确方法是什么?
doc.setFont("Zapfdingbats");
doc.setFontStyle("normal");
doc.text("\u2714", 20, 20, null, null, "left");
当我使用上述方法并在 iframe 中呈现 pdf 时,我通过警告消息收到错误消息 "Error in function Object.F (http://localhost:3000/static/js/1.chunk.js:26266:81): Failed to execute 'btoa' on 'Window': The string to be encoded contains characters outside of the Latin1 range."
注意:我正在使用 create-react-app 在我的 React 应用程序中使用它。
当我尝试时:
doc.text(btoa(unescape(encodeURIComponent("\u2714"))), 20, 20, null, null, "left");
我得到了复选标记,但还有三个我不想要的附加符号。
复选标记字形映射到“4”
doc.text("4", xPosition, yPosition, null, null, "left");
关于答案的问题:你怎么知道复选标记映射到“4”?我正在尝试使用 Symbol 字体中的商标 (TM),但还没有弄清楚该怎么做。 我能够使用上面的答案在我想要 TM 的地方打勾。如果我能找到 Symbol 字体的正确映射,它应该可以工作。 (我试过“\u2122”,但它在文件中的结果就像 py!)