使用 Pandoc 和 LaTeX 从 docx 转换为 pdf 时,如何修复“缺少字符”警告?

Bri*_*all 8 pdf latex docx file-conversion pandoc

目标

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

背景

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

尝试 1

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

pandoc transcription.docx  -s -o transcript.pdf

Run Code Online (Sandbox Code Playgroud)

我收到以下错误:

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.
Run Code Online (Sandbox Code Playgroud)

尝试 2

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

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

Run Code Online (Sandbox Code Playgroud)

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;!
...
Run Code Online (Sandbox Code Playgroud)

此过程会生成 PDF(请参阅https://briancroxall.net/pandoc/transcript.pdf),但大部分内容为空。

问题

尽我所知,这表明高棉字符在我试图用来进行转换的 LaTeX 引擎中不可用。无论是否如此,我如何才能成功管理此文件转换?

Bri*_*all 6

mb21 的评论帮助我解决了这个问题。由于我的系统安装了几种高棉字体,我不得不设置mainfont使用其中一种。

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

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

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