pdf-engine-fallback
Skill này làm gì
Skill này là kế hoạch thử lại việc tạo PDF bằng pandoc, thử các engine khác khi engine mặc định thất bại. Dành cho người tạo PDF từ tài liệu có ký tự không phải tiếng Anh hoặc ký tự đặc biệt, hoặc trong quy trình tự động.
Khi nào nên dùng
- ✓Khi việc tạo PDF bằng pandoc thất bại với một lỗi.
- ✓Khi tài liệu có văn bản không phải ASCII như chữ có dấu hoặc chữ không dùng bảng chữ cái Latinh.
- ✓Khi quy trình tài liệu của tôi phải tạo PDF trên các máy tính với thiết lập khác nhau.
Liên kết skill
https://github.com/HKUDS/AgentPilot/blob/main/openspace/benchmarks/gdpval/skills/pdf-engine-fallback/SKILL.mdSao 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
Dành cho Claude Code, Codex hoặc Cursor: chạy lệnh trong thư mục dự án của bạn và skill sẽ được cài đặt.
Tải tệp SKILL.md về và thả vào thư mục skill của agent.
Ví dụ cách nhờ AI
“Pandoc không tạo được PDF từ tài liệu của tôi, có chữ có dấu và chữ Trung Quốc. Hãy kiểm tra các engine và thử lại với engine xử lý được những ký tự đó.”
5 skill mới mỗi tuần. Đọc chỉ 1 phút.
Cách hoạt động
AI thử chuyển đổi mặc định trước, khi thất bại thì kiểm tra các PDF engine đã được cài, rồi thử lại với engine phù hợp nội dung, như xelatex cho Unicode hoặc wkhtmltopdf cho bố cục kiểu web.
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.
PDF Engine Fallback
This skill provides a diagnostic-retry workflow for PDF generation when Pandoc's default PDF engine fails. It systematically checks available engines and retries with alternatives optimized for different content types (e.g., xelatex for Unicode).
When to Use
- Pandoc PDF generation fails with errors
- Document contains non-ASCII characters (Unicode, CJK, etc.)
- Need robust PDF generation across different system configurations
- Working in CI/CD or automated document pipelines
Steps
1. Attempt Initial PDF Generation
First, try generating with pandoc's default engine:
pandoc input.md -o output.pdf
2. Diagnose on Failure
If the initial attempt fails, check which PDF engines are available:
# Check for pdflatex
which pdflatex && echo "pdflatex: available" || echo "pdflatex: not found"
# Check for xelatex (better Unicode support)
which xelatex && echo "xelatex: available" || echo "xelatex: not found"
# Check for wkhtmltopdf (HTML-based rendering)
which wkhtmltopdf && echo "wkhtmltopdf: available" || echo "wkhtmltopdf: not found"
3. Retry with Alternative Engine
Based on available engines and document content, retry with an appropriate engine:
# For documents with Unicode/special characters - prefer xelatex
pandoc input.md -o output.pdf --pdf-engine=xelatex
# Alternative: use pdflatex for simple Latin documents
pandoc input.md -o output.pdf --pdf-engine=pdflatex
# For HTML-heavy content or complex layouts
pandoc input.md -o output.pdf --pdf-engine=wkhtmltopdf
4. Handle Missing Engines
If no PDF engines are available, install one:
# Ubuntu/Debian - install texlive with xelatex
sudo apt-get install texlive-xetex
# Or install minimal teTeX
sudo apt-get install texlive-latex-base texlive-latex-extra
# macOS with Homebrew
brew install basictex
Complete Fallback Script
#!/bin/bash
# pdf-fallback.sh - Robust PDF generation with engine fallback
INPUT_FILE="${1:-input.md}"
OUTPUT_FILE="${2:-output.pdf}"
echo "Attempting PDF generation: $INPUT_FILE -> $OUTPUT_FILE"
# Try default engine first
if pandoc "$INPUT_FILE" -o "$OUTPUT_FILE" 2>/dev/null; then
echo "SUCCESS: PDF generated with default engine"
exit 0
fi
echo "Default engine failed. Checking available engines..."
# Check and try engines in priority order
if command -v xelatex &>/dev/null; then
echo "Retrying with xelatex (Unicode support)..."
if pandoc "$INPUT_FILE" -o "$OUTPUT_FILE" --pdf-engine=xelatex; then
echo "SUCCESS: PDF generated with xelatex"
exit 0
fi
fi
if command -v pdflatex &>/dev/null; then
echo "Retrying with pdflatex..."
if pandoc "$INPUT_FILE" -o "$OUTPUT_FILE" --pdf-engine=pdflatex; then
echo "SUCCESS: PDF generated with pdflatex"
exit 0
fi
fi
if command -v wkhtmltopdf &>/dev/null; then
echo "Retrying with wkhtmltopdf..."
if pandoc "$INPUT_FILE" -o "$OUTPUT_FILE" --pdf-engine=wkhtmltopdf; then
echo "SUCCESS: PDF generated with wkhtmltopdf"
exit 0
fi
fi
echo "FAILURE: No available PDF engine succeeded"
echo "Install a PDF engine (texlive-xetex recommended) and retry"
exit 1
Usage
# Make executable
chmod +x pdf-fallback.sh
# Run with defaults (input.md -> output.pdf)
./pdf-fallback.sh
# Run with custom files
./pdf-fallback.sh report.md report.pdf
Engine Selection Guide
| Engine | Best For | Unicode | Speed |
|---|---|---|---|
| xelatex | Non-Latin scripts, modern fonts | Excellent | Moderate |
| pdflatex | Simple Latin documents | Limited | Fast |
| wkhtmltopdf | HTML/CSS styling | Good | Fast |
Troubleshooting
- Font errors: Install required fonts or use xelatex with system fonts
- Package errors: Install missing LaTeX packages via
tlmgr - Large documents: Try pdflatex for speed, xelatex for compatibility
- Citation issues: Ensure pandoc-citeproc or citeproc is installed
Câu hỏi thường gặp
Vì sao dùng xelatex cho Unicode?
Hướng dẫn nói xelatex hỗ trợ đầy đủ Unicode, phù hợp với văn bản có dấu và không phải Latinh.
Các engine được kiểm tra thế nào?
AI chạy lệnh which cho từng engine để xem nó có được cài không.
Khi nào dùng pdflatex?
Hướng dẫn gợi ý pdflatex cho tài liệu đơn giản chỉ có văn bản Latinh thuần.
Chi tiết
Mô tả gốc của tác giả
Retry PDF generation with alternative engines when pandoc fails
repo: HKUDS/AgentPilot
Độ phổ biến
- Sao GitHub
- 7.8k
- Vị trí xếp hạng
- #12920
- Giấy phép
- MIT
- Cập nhật
- 1/11/2026
Bình luận
- …
Thêm skill từ kho mã này
agentpilot
7.8kGiúp agent của bạn cải thiện dự án từng bước bằng cách chuẩn bị tác vụ và chạy vòng lặp AgentPilot, gồm đề xuất, kiểm thử và chấm điểm thay đổi.
openspace
7.8kGiúp agent của bạn thiết lập OpenSpace, công cụ lưu và lấy lại skill của agent, rồi kết nối nó với ứng dụng AI của bạn qua MCP.
rsi-arena
7.8kGiúp agent của bạn thiết lập và chạy các bài kiểm thử benchmark AI chuẩn, như AIME và Terminal-Bench, để so sánh các phương pháp cải tiến khác nhau.
experiment-guide
7.8kGiúp agent của bạn lên kế hoạch các thí nghiệm nhỏ, đọc kết quả và ghi lại phát hiện khi tìm cách cải thiện một chương trình.
Skill tương tự
feishu-doc
394kGiúp agent của bạn đọc, tạo và sửa tài liệu đám mây Feishu, gồm văn bản, hình ảnh và bảng, bằng công cụ tài liệu.
feishu-drive
394kCho phép agent của bạn duyệt, sắp xếp và bình luận các file trong một thư mục đám mây Feishu đã được chia sẻ với bot.
feishu-perm
394kGiúp agent của bạn kiểm tra và thay đổi ai có quyền truy cập một file Feishu, chọn quyền nhỏ nhất đáp ứng yêu cầu của bạn.