본문으로 건너뛰기
Skillpedia
PDF, Word, 슬라이드7.8k · #12920

pdf-engine-fallback

하는 일

이 스킬은 기본 엔진이 실패할 때 pandoc PDF 생성을 다른 엔진으로 다시 시도하는 계획입니다. 악센트나 라틴 문자가 아닌 글자가 있는 문서, 또는 자동화된 파이프라인에서 PDF를 만드는 사람에게 맞습니다.

사용하는 경우

  • ✓pandoc PDF 생성이 오류와 함께 실패할 때.
  • ✓문서에 악센트 글자나 라틴 문자가 아닌 글자 같은 특수한 텍스트가 있는 경우.
  • ✓서로 다른 설정의 컴퓨터에서 문서 파이프라인으로 PDF를 만들어야 할 때.

스킬 링크

https://github.com/HKUDS/AgentPilot/blob/main/openspace/benchmarks/gdpval/skills/pdf-engine-fallback/SKILL.md

복사해서 AI(Claude, ChatGPT, Cursor)에 붙여넣고 지침을 따르도록 요청하세요.

사용 방법

가장 쉬운 방법입니다. 메시지를 복사해 AI에 붙여넣으세요. AI가 스킬을 읽고 지침을 따릅니다.

바로 붙여넣을 수 있는 메시지

Use this skill to help me: https://github.com/HKUDS/AgentPilot/blob/main/openspace/benchmarks/gdpval/skills/pdf-engine-fallback/SKILL.md Read the SKILL.md file at that link and follow its instructions for my task.
AI가 이런 스킬을 알아서 찾아 쓰길 원하시나요?무료 Skillpedia MCP를 설치하세요. 한 줄이면 작업마다 스킬 15,000+개 중에서 검색합니다.1분 만에 설치 →

AI에게 요청하는 예시

“제 문서에 악센트 글자와 중국어가 있어서 pandoc이 PDF를 만들지 못합니다. 설치된 엔진을 확인하고, 이런 문자를 다룰 수 있는 엔진으로 다시 시도해 주세요.”

매주 새 스킬 5개. 읽는 데 1분.

작동 방식

AI는 먼저 기본 변환을 시도하고, 실패하면 설치된 PDF 엔진을 확인한 뒤, 내용에 맞는 엔진으로 다시 시도합니다. 유니코드에는 xelatex, 웹 스타일 레이아웃에는 wkhtmltopdf를 씁니다.

기술 내용 (원본 SKILL.md)

작성자의 영어 원문을 GitHub에서 그대로 가져왔습니다.

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
자주 묻는 질문

유니코드에 xelatex를 쓰는 이유는 무엇인가요?

가이드는 xelatex가 완전한 유니코드 지원을 갖춰 악센트와 라틴 문자가 아닌 글자에 맞는다고 말합니다.

엔진은 어떻게 확인하나요?

AI는 각 엔진마다 which 명령을 실행해 설치 여부를 확인합니다.

pdflatex는 언제 쓰나요?

가이드는 일반 라틴 문자로 된 간단한 문서에 pdflatex를 추천합니다.

상세 정보

작성자의 원본 설명

Retry PDF generation with alternative engines when pandoc fails

repo: HKUDS/AgentPilot

인기도

GitHub 스타
7.8k
순위
#12920
라이선스
MIT
업데이트
2026. 11. 1.

이 스킬이 유용한가요?

0

로그인 투표하려면 로그인하세요.

댓글

  • …

이 저장소의 다른 스킬

비슷한 스킬