【问题标题】:How do I fix "missing character" warnings when converting from docx to pdf using Pandoc and LaTeX?使用 Pandoc 和 LaTeX 从 docx 转换为 pdf 时,如何修复“缺少字符”警告?
【发布时间】:2020-06-17 12:00:49
【问题描述】:

目标

我有几千个高棉语.docx 文件,并希望使用Pandoc 将它们转换为.pdf 格式。

背景

我使用 MacPorts 安装了 Pandoc。 Pandoc需要LaTeX进行PDF转换,所以我安装了MacTeX。安装似乎很顺利,我已经能够毫无困难地将英文的.docx 文件转换为.pdf

尝试 1

当我尝试将高棉语文件(您可以在https://briancroxall.net/pandoc/transcription.docx 找到示例)转换为 PDF 时,我使用以下命令:

pandoc transcription.docx  -s -o transcript.pdf

我收到以下错误:

Error producing PDF.
! Package inputenc Error: Unicode character អ (U+17A2)
(inputenc)                not set up for use with LaTeX.

See the inputenc package documentation for explanation.
Type  H <return>  for immediate help.
 ...                                              

l.64 ...�នៅសម័យប៉ុល ពត។}

Try running pandoc with --pdf-engine=xelatex.

尝试 2

按照这个建议,我使用这个命令:

pandoc --pdf-engine=xelatex transcription.docx  -s -o transcript.pdf

Pandoc 然后为文本中的每个高棉字符抛出错误消息:

[WARNING] Missing character: There is no អ in font [lmroman10-bold]:mapping=tex-text;!
[WARNING] Missing character: There is no ្ in font [lmroman10-bold]:mapping=tex-text;!
[WARNING] Missing character: There is no ន in font [lmroman10-bold]:mapping=tex-text;!
...

此过程会生成一个 PDF(请参阅 https://briancroxall.net/pandoc/transcript.pdf),但它大部分是空的。

问题

据我所知,这表明高棉字符在我试图用来进行转换的 LaTeX 引擎中不可用。不管是不是这样,我怎样才能成功地管理这个文件转换?

【问题讨论】:

标签: pdf latex docx pandoc file-conversion


【解决方案1】:

mb21's comment 帮我解决了这个问题。由于我的系统安装了几种高棉字体,我必须设置mainfont 才能使用其中一种。

$ pandoc --pdf-engine=xelatex transcription.docx \ 
      -V 'mainfont:Khmer MN' -s -o transcription.pdf

这会生成带有高棉字符且没有错误消息的 PDF。

PDF 确实 似乎存在一些问题,因为高棉语中的某些短语超出了页面的边缘。我认为这是由于 Word 能够处理的分段问题,但在转换为 PDF 时却搞砸了。

【讨论】:

    猜你喜欢
    • 2021-03-18
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-08-14
    • 2019-10-16
    相关资源
    最近更新 更多