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

pdf-gen-fallback-dee20c

하는 일

이 스킬은 라이브러리 확인과 눈에 보이는 오류 처리를 갖춘 PDF 생성 예비 방법입니다. 이유가 불분명하게 샌드박스에서 PDF나 보고서 작업이 실패하는 사람에게 맞습니다.

사용하는 경우

  • ✓PDF나 보고서를 만드는 중 샌드박스가 불분명한 오류를 낼 때.
  • ✓무엇이 잘못됐는지 알 수 있도록 오류 메시지를 보고 싶을 때.
  • ✓컴퓨터에 파일로 저장되는 간단한 PDF가 필요한 경우.

스킬 링크

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

AI에게 요청하는 예시

“제 제목과 텍스트로 간단한 PDF를 만들어 주세요. 샌드박스가 분명한 메시지 없이 실패하니 셸에서 실행하고 오류가 있으면 보여 주세요.”

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

작동 방식

AI는 필요한 라이브러리를 확인한 뒤, PDF를 쓰고 성공 메시지를 출력하는 Python 스크립트를 셸에서 실행합니다. 코드는 오류 처리로 감싸져 있습니다.

기술 내용 (원본 SKILL.md)

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

PDF Generation Fallback Workflow

Purpose

When execute_code_sandbox returns opaque or unhelpful errors during document/PDF generation, use run_shell with direct python -c execution as a reliable alternative. This pattern includes library availability checks and explicit error handling.

When to Use

  • execute_code_sandbox fails with unclear error messages during document generation
  • PDF, report, or document creation tasks are failing unexpectedly
  • You need more control over the Python execution environment

Step-by-Step Instructions

1. Check Library Availability

Before attempting generation, verify required libraries are installed:

run_shell: python -c "import reportlab; print('reportlab OK')"
run_shell: python -c "import fpdf; print('fpdf OK')"
run_shell: python -c "import PyPDF2; print('PyPDF2 OK')"

If a library is missing, install it:

run_shell: pip install reportlab --quiet

2. Execute Generation via run_shell

Instead of execute_code_sandbox, use run_shell with python -c:

run_shell: python -c "
from reportlab.lib.pagesizes import letter
from reportlab.pdfgen import canvas
c = canvas.Canvas('output.pdf', pagesize=letter)
c.drawString(100, 750, 'Document Content')
c.save()
print('PDF generated successfully')
"

3. Handle Errors Explicitly

Wrap generation code with try/except and capture stderr:

run_shell: python -c "
import sys
try:
    # Your generation code here
    from reportlab.pdfgen import canvas
    c = canvas.Canvas('output.pdf')
    c.drawString(100, 750, 'Content')
    c.save()
    print('SUCCESS: PDF created')
    sys.exit(0)
except Exception as e:
    print(f'ERROR: {type(e).__name__}: {e}', file=sys.stderr)
    sys.exit(1)
" 2>&1

4. Verify Output File

After generation, confirm the file was created:

run_shell: ls -la output.pdf
run_shell: file output.pdf

5. Fallback Hierarchy

If the first approach fails, try alternatives in this order:

  1. reportlab - Full-featured PDF generation
  2. fpdf - Simpler PDF library
  3. wkhtmltopdf - HTML to PDF conversion
  4. Direct text/Markdown output as last resort

Example: Complete Workflow

# Step 1: Check library
run_shell: python -c "import reportlab; print('OK')"

# Step 2: Generate with error handling
run_shell: python -c "
import sys
try:
    from reportlab.lib.pagesizes import letter
    from reportlab.pdfgen import canvas
    c = canvas.Canvas('report.pdf', pagesize=letter)
    c.setTitle('Surveillance Report')
    c.drawString(100, 750, 'Revised Surveillance Report')
    c.drawString(100, 730, 'Summary: Key findings documented')
    c.save()
    print('SUCCESS')
except Exception as e:
    print(f'FAILED: {e}', file=sys.stderr)
    sys.exit(1)
"

# Step 3: Verify
run_shell: test -f report.pdf && echo 'File exists' || echo 'File missing'

Troubleshooting

Issue Solution
Module not found pip install <module> --quiet
Permission denied Check output directory permissions
Font errors Use default fonts or install font packages
Encoding issues Specify encoding explicitly in string operations

Best Practices

  • Always capture both stdout and stderr for debugging
  • Exit with proper status codes (0 for success, 1 for failure)
  • Keep generation code concise when using python -c
  • For complex generation, write a temporary .py file instead
  • Test library availability before attempting generation
자주 묻는 질문

코드를 오류 처리로 감싸는 이유는 무엇인가요?

가이드는 실패를 숨기지 않고 분명하게 보이게 한다고 설명합니다.

스크립트는 마지막에 무엇을 출력하나요?

성공 메시지를 출력해서 결과를 쉽게 확인할 수 있게 합니다.

예제는 어떤 라이브러리를 쓰나요?

예제는 reportlab의 canvas로 텍스트를 그리고 PDF를 저장합니다.

상세 정보

작성자의 원본 설명

Fallback workflow for document generation when code sandbox returns opaque errors

repo: HKUDS/AgentPilot

인기도

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

이 스킬이 유용한가요?

0

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

댓글

  • …

이 저장소의 다른 스킬

비슷한 스킬