Chuyển đến nội dung
Skillpedia
PDF, Word và slide7.8k · #12903

pandoc-pdf-error-diagnosis

Skill này làm gì

Skill này là quy trình chẩn đoán cho các lỗi PDF của pandoc chỉ báo là lỗi không rõ. Dành cho người chuyển Markdown hoặc tài liệu khác sang PDF và cần biết nguyên nhân thật.

Khi nào nên dùng

  • ✓Khi pandoc báo lỗi không rõ trong lúc chuyển sang PDF.
  • ✓Khi chuyển sang các định dạng khác vẫn chạy nhưng bước PDF thất bại.
  • ✓Khi tôi cần biết PDF engine nào đã được cài trên máy tính này.

Liên kết skill

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

Sao chép rồi dán vào AI của bạn (Claude, ChatGPT hoặc Cursor) và nhờ nó làm theo hướng dẫn.

Cách dùng

Cách dễ nhất: sao chép tin nhắn và dán vào AI của bạn. AI sẽ đọc skill và làm theo hướng dẫn.

Tin nhắn có sẵn để dán

Hãy dùng skill này để giúp tôi: https://github.com/HKUDS/AgentPilot/blob/main/openspace/benchmarks/gdpval/skills/pandoc-pdf-error-diagnosis/SKILL.md Đọc tệp SKILL.md tại liên kết đó và làm theo hướng dẫn cho việc của tôi.
Bạn muốn AI tự tìm những skill như thế này?Cài MCP Skillpedia miễn phí: chỉ một dòng, và AI sẽ tìm trong 15.000+ skill trước mỗi việc.Cài đặt trong 1 phút →

Ví dụ cách nhờ AI

“Pandoc báo lỗi không rõ khi tôi tạo PDF từ Markdown. Hãy tìm xem có gì sai và sửa nó.”

5 skill mới mỗi tuần. Đọc chỉ 1 phút.

Cách hoạt động

AI kiểm tra pandoc đã được cài chưa, liệt kê các PDF engine có sẵn, thử chuyển đổi với một engine đã chọn trong khi lưu toàn bộ đầu ra lỗi, rồi đọc đầu ra để tìm nguyên nhân.

Nội dung kỹ thuật (SKILL.md gốc)

Lấy nguyên văn từ GitHub, do tác giả viết bằng tiếng Anh.

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
Câu hỏi thường gặp

pandoc có tự tạo PDF không?

Không. Hướng dẫn lưu ý rằng pandoc dựa vào một PDF engine bên ngoài để tạo tệp.

Nên thử engine nào trước?

Hướng dẫn gợi ý xelatex trước vì nó xử lý Unicode và phông chữ tốt.

Vì sao lưu đầu ra lỗi vào nhật ký?

Nhật ký giữ đầy đủ thông báo, nên có thể tìm nguyên nhân thật ngay cả khi màn hình chỉ hiện một lỗi ngắn.

Chi tiết

Mô tả gốc của tác giả

Systematic diagnostic workflow for resolving pandoc PDF conversion errors

repo: HKUDS/AgentPilot

Độ phổ biến

Sao GitHub
7.8k
Vị trí xếp hạng
#12903
Giấy phép
MIT
Cập nhật
1/11/2026

Skill này có hữu ích không?

0

Đăng nhập để bình chọn.

Bình luận

  • …

Thêm skill từ kho mã này

Skill tương tự