跳到正文
Skillpedia
PDF、Word 与幻灯片7.8k · #12903

pandoc-pdf-error-diagnosis

它能做什么

这项技能是针对 pandoc PDF 错误的诊断流程,适用于只显示模糊未知错误的情况。适合把 Markdown 或其他文档转换为 PDF、需要找出真正原因的人。

适用场景

  • ✓当 pandoc 在转换为 PDF 时报告未知错误时。
  • ✓当转换为其他格式正常,但 PDF 这一步失败时。
  • ✓当我需要知道这台电脑上安装了哪个 PDF 引擎时。

技能链接

https://github.com/HKUDS/AgentPilot/blob/main/openspace/benchmarks/gdpval/skills/pandoc-pdf-error-diagnosis/SKILL.md

复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。

使用方法

最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。

可直接粘贴的消息

请用这个技能帮我:https://github.com/HKUDS/AgentPilot/blob/main/openspace/benchmarks/gdpval/skills/pandoc-pdf-error-diagnosis/SKILL.md 阅读该链接中的 SKILL.md 文件,并在我的任务中按照它的说明来做。
想让你的 AI 自己找到这样的技能吗?安装免费的 Skillpedia MCP:只需一行,每次任务前它都会在 15,000+ 个技能中搜索。1 分钟完成安装 →

可以这样问 AI

“请帮我:我把 Markdown 转换为 PDF 时,pandoc 只提示未知错误。请查明原因并修复。”

每周 5 个新技能,1 分钟读完。

工作原理

AI 先检查 pandoc 是否已安装,列出可用的 PDF 引擎,用选定的引擎尝试转换并保存完整错误输出,然后阅读输出以找出原因。

技术内容(原始 SKILL.md)

作者在 GitHub 上的英文原文。

Pandoc PDF Error Diagnosis Workflow

When pandoc reports an "unknown error" during PDF conversion, follow this systematic diagnostic workflow to identify and resolve the issue.

Step 1: Verify Pandoc Installation

First, confirm pandoc is installed and check its version:

pandoc --version

This verifies pandoc is available and shows which version and features are supported.

Step 2: Check Available PDF Engines

Identify which PDF rendering engines are installed on the system:

which pdflatex xelatex lualatex wkhtmltopdf

Common engines and their characteristics:

  • pdflatex: Fast, widely available, good for simple documents
  • xelatex: Better Unicode/font support, handles modern fonts well
  • lualatex: Advanced Lua scripting, modern TeX features
  • wkhtmltopdf: HTML-to-PDF via WebKit, good for web-styled content

Step 3: Attempt Conversion with Explicit Engine

Try conversion with an explicit engine specification, starting with xelatex (most forgiving):

pandoc input.md -o output.pdf --pdf-engine=xelatex

Important: Capture the full stderr output for diagnosis:

pandoc input.md -o output.pdf --pdf-engine=xelatex 2>&1 | tee conversion.log

Step 4: Analyze Error Output

Examine the captured stderr for common issues:

Error Pattern Likely Cause Solution
xelatex not found Engine not installed Install TeX Live or try different engine
Package xyz not found Missing LaTeX package Install missing package or remove feature
Font xyz not found Missing font Install font or change document fonts
LaTeX Error: File xyz.sty not found Missing style file Install texlive-extra or simplify document

Step 5: Fallback Strategy

If the primary engine fails, try alternatives in order:

# Try pdflatex (most basic)
pandoc input.md -o output.pdf --pdf-engine=pdflatex 2>&1

# Try lualatex (if xelatex failed)
pandoc input.md -o output.pdf --pdf-engine=lualatex 2>&1

# Try wkhtmltopdf (for HTML-heavy content)
pandoc input.md -o output.pdf --pdf-engine=wkhtmltopdf 2>&1

Step 6: Install Missing Dependencies (if possible)

If a specific engine is needed but missing:

# Debian/Ubuntu
sudo apt-get install texlive-xetex texlive-fonts-recommended

# macOS with Homebrew
brew install --cask mactex-no-gui

# Check what's available
tlmgr install <package-name>

Step 7: Simplify and Retry

If all engines fail, simplify the source document:

  1. Remove complex tables or math
  2. Replace custom fonts with standard fonts
  3. Split large documents into sections
  4. Convert to intermediate format first (e.g., HTML then PDF)

Quick Reference Diagnostic Script

#!/bin/bash
# pandoc-pdf-diagnose.sh

INPUT="${1:-input.md}"
OUTPUT="${2:-output.pdf}"

echo "=== Pandoc PDF Conversion Diagnosis ==="
echo "Input: $INPUT"
echo "Output: $OUTPUT"
echo ""

echo "1. Pandoc version:"
pandoc --version | head -1
echo ""

echo "2. Available engines:"
for engine in pdflatex xelatex lualatex wkhtmltopdf; do
    if which $engine > /dev/null 2>&1; then
        echo "  ✓ $engine: $(which $engine)"
    else
        echo "  ✗ $engine: not found"
    fi
done
echo ""

echo "3. Attempting conversion with xelatex:"
pandoc "$INPUT" -o "$OUTPUT" --pdf-engine=xelatex 2>&1

if [ $? -eq 0 ]; then
    echo "✓ Conversion successful!"
else
    echo "✗ Conversion failed. Try alternative engines."
fi

When to Use This Skill

  • Pandoc reports "unknown error" during PDF conversion
  • PDF output is empty or corrupted
  • Need to determine which PDF engine works best for a document
  • Troubleshooting CI/CD pipeline document generation failures
常见问题

pandoc 自己能生成 PDF 吗?

不能。指南说明 pandoc 需要依赖外部 PDF 引擎来生成文件。

建议先尝试哪个引擎?

指南建议先试 xelatex,因为它对 Unicode 和字体的支持较好。

为什么要把错误输出保存到日志?

日志会保留完整的信息,即使屏幕上只显示简短的错误,也能找到真正原因。

详情

作者的原始描述

Systematic diagnostic workflow for resolving pandoc PDF conversion errors

repo: HKUDS/AgentPilot

热度

GitHub 星标
7.8k
排名
#12903
许可证
MIT
更新时间
2026/11/1

这个技能有用吗?

0

登录 后即可投票。

评论

  • …

同一仓库的更多技能

相似技能