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

pandoc-pdf-error-resolution

Skill này làm gì

Skill này cung cấp cách có cấu trúc để giải quyết lỗi chuyển đổi PDF của pandoc khi thông báo không rõ ràng. Dành cho người chuyển tài liệu sang PDF và gặp thông báo lỗi không rõ.

Khi nào nên dùng

  • ✓Khi pandoc trả về lỗi không rõ trong lúc chuyển đổi PDF.
  • ✓Khi cùng một tài liệu chuyển được sang HTML hoặc Markdown nhưng không sang PDF.
  • ✓Khi tôi cần biết PDF engine nào hoạt động 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-resolution/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-resolution/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 không chuyển được tài liệu của tôi thành PDF và chỉ báo lỗi không rõ. Hãy tìm engine PDF nào hoạt động và tạo tệp.”

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

Cách hoạt động

AI kiểm tra phiên bản pandoc, tìm pdflatex, xelatex, lualatex và wkhtmltopdf, thử lại chuyển đổi với một engine cụ thể, và đọc lỗi để quyết định cần thay đổi gì.

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 Resolution

This skill provides a step-by-step workflow for diagnosing and resolving "unknown error" messages when using pandoc to generate PDFs.

When to Use

Use this skill when:

  • Pandoc returns an "unknown error" during PDF conversion
  • The conversion succeeds for other formats (e.g., markdown, HTML) but fails for PDF
  • You need to identify which PDF engine is available and working

Step-by-Step Procedure

Step 1: Verify Pandoc Installation

First, confirm pandoc is installed and check its version:

pandoc --version

This confirms pandoc is available and shows the version number. Note that pandoc itself doesn't generate PDFs directly—it delegates to external PDF engines.

Step 2: Check Available PDF Engines

Identify which PDF engines are installed on the system:

which pdflatex xelatex lualatex wkhtmltopdf pdfroff 2>/dev/null || echo "Checking individual engines..."
which pdflatex
which xelatex
which lualatex
which wkhtmltopdf

Common engines and their characteristics:

  • pdflatex: Fast, widely available, good for basic documents
  • xelatex: Better Unicode/font support, recommended for complex documents
  • lualatex: Advanced typography, Lua scripting support
  • wkhtmltopdf: HTML-to-PDF conversion, good for web-style documents

Step 3: Attempt Conversion with Explicit Engine

Retry the conversion with an explicit --pdf-engine flag:

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

Try engines in this order:

  1. xelatex (best Unicode support)
  2. pdflatex (most widely available)
  3. lualatex (if xelatex fails)
  4. wkhtmltopdf (for HTML-heavy content)

Step 4: Capture Full stderr Output

Always capture the complete error output before falling back:

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

This preserves the full error message for analysis. Common error patterns:

  • Font errors: Missing LaTeX packages or fonts
  • Package errors: Missing LaTeX packages (use tlmgr install <package>)
  • Syntax errors: Issues in the source document

Step 5: Install Missing Dependencies (if needed)

If errors indicate missing LaTeX packages:

# For TeX Live
tlmgr install <package-name>

# For Debian/Ubuntu
apt-get install texlive-latex-extra texlive-fonts-recommended

# For macOS with Homebrew
brew install --cask mactex

Step 6: Fallback Strategies

If all engines fail, consider:

  1. Convert to HTML first, then use wkhtmltopdf
  2. Simplify the document (remove complex formatting)
  3. Use an online conversion service
  4. Generate PDF from a different format (e.g., DOCX via LibreOffice)

Example Complete Workflow

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

INPUT_FILE="$1"
OUTPUT_FILE="${INPUT_FILE%.md}.pdf"

echo "=== Pandoc PDF Conversion Debug ==="
echo "Input: $INPUT_FILE"
echo "Output: $OUTPUT_FILE"

# Step 1: Verify pandoc
echo -e "\n[1] Checking pandoc version..."
pandoc --version | head -1

# Step 2: Check engines
echo -e "\n[2] Checking available PDF engines..."
for engine in pdflatex xelatex lualatex wkhtmltopdf; do
    if which "$engine" &>/dev/null; then
        echo "  ✓ $engine: $(which $engine)"
    else
        echo "  ✗ $engine: not found"
    fi
done

# Step 3: Try conversion with xelatex
echo -e "\n[3] Attempting conversion with xelatex..."
pandoc "$INPUT_FILE" -o "$OUTPUT_FILE" --pdf-engine=xelatex 2>&1 | tee /tmp/pandoc_error.log

if [ $? -eq 0 ]; then
    echo "✓ Conversion successful!"
else
    echo "✗ Conversion failed. Check /tmp/pandoc_error.log for details"
    echo "Attempting fallback with pdflatex..."
    pandoc "$INPUT_FILE" -o "$OUTPUT_FILE" --pdf-engine=pdflatex 2>&1
fi

Quick Reference

Command Purpose
pandoc --version Verify pandoc installation
which xelatex Check if xelatex engine exists
pandoc file.md -o file.pdf --pdf-engine=xelatex Convert with explicit engine
... 2>&1 | tee error.log Capture full stderr output
tlmgr install <pkg> Install missing LaTeX package
Câu hỏi thường gặp

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

Không. Hướng dẫn giải thích rằng pandoc giao việc cho một PDF engine bên ngoài.

Vì sao kiểm tra các định dạng khác?

Nếu các định dạng khác chạy được, vấn đề rất có thể nằm ở PDF engine chứ không phải tài liệu.

Engine nào tốt hơn cho Unicode?

Hướng dẫn mô tả xelatex có hỗ trợ Unicode và phông chữ tốt hơn pdflatex.

Chi tiết

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

Systematic debugging workflow for pandoc PDF conversion errors

repo: HKUDS/AgentPilot

Độ phổ biến

Sao GitHub
7.8k
Vị trí xếp hạng
#12905
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ự