本文介绍了将Zapfdingbats与jsPDf一起使用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用jsPDf和内置Zapfdingbats字体在PDF文档中添加一个选中标记作为文本,但是遇到了问题.用这种字体访问字形的正确方法是什么?

I'm trying to add a checkmark as text to a pdf document with jsPDf and the built-in Zapfdingbats font, but I'm running into issues. What is the correct way to access the glyphs in this font?

doc.setFont("Zapfdingbats");
doc.setFontStyle("normal");
doc.text("\u2714", 20, 20, null, null, "left");

当我使用上述内容并在iframe中呈现pdf时,我通过一条警告消息收到一条错误消息,内容为函数Object.F( http://localhost:3000/static/js/1.chunk.js:26266:81 ):执行'btoa失败'on'Window':要编码的字符串包含Latin1范围之外的字符."

When I use the above and render the pdf in an iframe, I get an error message via an alert message saying "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应用中使用它.

Note: I'm using this in my react app using create-react-app.

当我尝试时:

doc.text(btoa(unescape(encodeURIComponent("\u2714"))), 20, 20, null, null, "left");

我得到了选中标记,但又得到了三个我不想要的符号.

I get the checkmark but also three additional symbols that I don't want.

推荐答案

选中标记字形已映射到"4"

Checkmark glyph is mapped to "4"

doc.text("4", xPosition, yPosition, null, null, "left");

这篇关于将Zapfdingbats与jsPDf一起使用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-22 13:13
查看更多