go - jung-kurt/gofpdf TM 商标符号未正确呈现
问题描述
stringTMSymbol := "™️"
pdf.TransformBegin()
pdf.TransformTranslate(x, y)
pdf.Line(0.0, 0.0, w, 0.0)
pdf.SetXY(0, 0.0)
pdf.SetFont("Arial", "", 14)
pdf.CellFormat(w, 0.33, "URN" + stringTMSymbol, "", 0, "C", false, 0, "")
pdf.Line(0, 0.32, w, 0.32)
pdf.TransformEnd()
代码示例会生成包含无法识别字符的 pdf:
这应该看起来像:
URN™️
我想这是一个字符编码问题。如何使用 jung-kurt/gofpdf 在 pdf 上渲染 ™️ 符号?
解决方案
解决了
https://godoc.org/github.com/jung-kurt/gofpdf#Fpdf.UnicodeTranslatorFromDescriptor
按照这个例子:
https://github.com/jung-kurt/gofpdf/issues/6
tr := pdf.UnicodeTranslatorFromDescriptor("")
pdf.CellFormat(w, 0.33, "URN" + tr(stringTMSymbol), "", 0, "C", false, 0, "")
推荐阅读
- r - 根据另一个数据表过滤一个数据表
- asp.net - 使用链接按钮在同一选项卡中打开链接
- sql - 我们如何返回与 SQL SERVER 中具有重复值的字段对应的列的 ID
- php - Yajra 数据表中出现错误
- android - 如何通过 USB 将命令从 android 发送到带有 windows 的 pc
- java - 我的 Android 功能区应用程序构建成功但无法运行
- c# - 如何编写带有缩进的阿拉伯语文本文件?
- java - 已安装 Java SE 开发工具包,但无法使用命令 javac
- cmd - 将每个名称相同的数千个文件移动到一个文件夹并重命名它们
- tfs - TFS 为运行任务构建自定义条件 - 检查特定的先前任务是否失败