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

pdf-generation-troubleshooting

하는 일

이 스킬은 pandoc에서 Python 라이브러리로 넘어가는 PDF 생성 3단계 계획입니다. 일부 도구가 없을 수 있을 때 Markdown을 변환하거나 PDF를 만드는 사람에게 맞습니다.

사용하는 경우

  • ✓Markdown이나 HTML 파일을 PDF로 바꿔야 할 때.
  • ✓pandoc이 없거나 변환에 실패하는 경우.
  • ✓다른 도구를 쓸 수 없어 Python으로 PDF를 처음부터 만들어야 할 때.

스킬 링크

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

AI에게 요청하는 예시

“이 Markdown을 PDF로 바꿔 주세요. 여기 pandoc이 없으면 Python 라이브러리를 대신 써 주세요.”

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

작동 방식

AI는 pandoc이 있는지 확인하고, 있으면 변환합니다. 없으면 reportlab을 확인하고 필요하면 설치하며, 마지막으로 fpdf2를 시도합니다.

기술 내용 (원본 SKILL.md)

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

PDF Generation Troubleshooting Workflow

This skill provides a systematic approach to generating PDFs when multiple tools may be unavailable. Follow this fallback sequence to ensure PDF generation succeeds.

Workflow Overview

  1. Try pandoc first (simplest for markdown/HTML conversion)
  2. Fallback to reportlab (Python library for programmatic PDFs)
  3. Fallback to fpdf2 (alternative Python PDF library)

Each step includes installation verification before execution.

Step 1: Attempt pandoc Conversion

Use pandoc for markdown or HTML to PDF conversion. Check availability first:

# Check if pandoc is available
which pandoc || echo "pandoc not found"

If available, convert:

pandoc input.md -o output.pdf

If pandoc fails or is unavailable, proceed to Step 2.

Step 2: Attempt reportlab

Check Installation

python3 -c "import reportlab" 2>/dev/null && echo "reportlab available" || echo "reportlab not found"

Install if Needed

pip install reportlab

Create PDF Script

Use write_file to create a Python script:

from reportlab.lib.pagesizes import letter
from reportlab.pdfgen import canvas

def create_pdf(filename, content):
    c = canvas.Canvas(filename, pagesize=letter)
    c.drawString(100, 750, content)
    c.save()

if __name__ == "__main__":
    create_pdf("output.pdf", "Your content here")

Execute Script

Use run_shell with proper directory context:

cd /path/to/working/directory && python3 script.py

If reportlab fails, proceed to Step 3.

Step 3: Attempt fpdf2

Check Installation

python3 -c "from fpdf import FPDF" 2>/dev/null && echo "fpdf2 available" || echo "fpdf2 not found"

Install if Needed

pip install fpdf2

Create PDF Script

from fpdf import FPDF

def create_pdf(filename, text):
    pdf = FPDF()
    pdf.add_page()
    pdf.set_font("Arial", size=12)
    pdf.cell(200, 10, txt=text, ln=True)
    pdf.output(filename)

if __name__ == "__main__":
    create_pdf("output.pdf", "Your content here")

Execute Script

cd /path/to/working/directory && python3 script.py

Decision Matrix

Tool Best For Limitations
pandoc Markdown/HTML conversion Requires external installation
reportlab Complex layouts, graphics Steeper learning curve
fpdf2 Simple text PDFs Limited formatting options

Error Handling Pattern

For each tool attempt:

  1. Check availability/installation
  2. Install if missing (pip install <package>)
  3. Create script using write_file
  4. Execute using run_shell with cd <dir> && <command>
  5. Verify output file exists
  6. If fails, move to next tool in sequence

Example Fallback Implementation

# Pseudocode for full workflow
if command -v pandoc >/dev/null 2>&1; then
    pandoc input.md -o output.pdf && exit 0
fi

if python3 -c "import reportlab" 2>/dev/null; then
    # Create and run reportlab script
    exit 0
fi

# Final fallback: fpdf2
pip install fpdf2
# Create and run fpdf2 script

Key Principles

  • Always verify tool availability before attempting use
  • Install on-demand when a tool is missing
  • Use write_file for script creation (ensures clean, versionable code)
  • Use run_shell with explicit directory context (cd <dir> && <cmd>)
  • Progressive fallback ensures at least one method succeeds
  • Verify output after each attempt before moving to next tool
자주 묻는 질문

첫 번째 선택은 무엇인가요?

pandoc입니다. Markdown이나 HTML 파일에 가장 간단한 선택지이기 때문입니다.

pandoc 다음에는 무엇을 쓰나요?

Python 라이브러리인 reportlab을 쓰고, reportlab이 작동하지 않으면 fpdf2를 씁니다.

도구를 쓰기 전에 확인하나요?

네, 각 단계는 실행 전에 설치 여부를 확인합니다.

상세 정보

작성자의 원본 설명

Systematic fallback workflow for PDF generation through pandoc, reportlab, and fpdf2 with installation verification

repo: HKUDS/AgentPilot

인기도

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

이 스킬이 유용한가요?

0

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

댓글

  • …

이 저장소의 다른 스킬

비슷한 스킬