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

pdf-gen-fallback

하는 일

이 스킬은 셸에서 Python으로 PDF와 보고서를 만드는 믿을 만한 방법입니다. 알아보기 어려운 샌드박스 오류 때문에 문서 생성이 계속 실패하는 사람에게 맞습니다.

사용하는 경우

  • ✓PDF나 보고서를 만드는 중 샌드박스가 알아보기 어려운 메시지로 실패할 때.
  • ✓이 컴퓨터에 PDF, 보고서 또는 문서를 만들어야 할 때.
  • ✓reportlab 같은 라이브러리를 쓸 수 없을 수도 있는 경우.

스킬 링크

https://github.com/HKUDS/AgentPilot/blob/main/openspace/benchmarks/gdpval/skills/pdf-gen-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-gen-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에게 요청하는 예시

“제 내용으로 PDF 보고서를 만들어 주세요. 샌드박스가 알아보기 어려운 오류로 계속 실패하니 라이브러리를 확인하고 다른 방법으로 만들어 주세요.”

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

작동 방식

AI는 먼저 샌드박스를 시도하고, 불분명하거나 import 오류가 나타나는지 살핀 뒤, 그런 오류가 있으면 라이브러리를 확인하고 셸에서 PDF를 만듭니다.

기술 내용 (원본 SKILL.md)

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

PDF Generation Fallback

This skill provides a reliable workflow for generating PDFs and documents when execute_code_sandbox returns opaque errors. Use direct run_shell with python -c as a fallback, with library availability checks and explicit error handling.

When to Use

  • execute_code_sandbox fails with cryptic error messages during document/PDF generation
  • You need to generate PDFs, reports, or structured documents
  • Standard library execution is unreliable for document creation tasks

Step-by-Step Procedure

Step 1: Check Library Availability

Before attempting generation, verify that required libraries are installed:

run_shell command="python -c \"import reportlab; print('reportlab available')\""
run_shell command="python -c \"import fpdf; print('fpdf available')\""
run_shell command="python -c \"import pypdf; print('pypdf available')\""

Step 2: Attempt execute_code_sandbox First

Try the sandbox approach initially (it's cleaner for iteration):

execute_code_sandbox code="""
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("ARTIFACT_PATH:/path/to/output.pdf")
"""

Step 3: Detect Opaque Errors

Watch for these failure indicators:

  • Generic "execution failed" messages
  • Import errors that don't match library availability checks
  • Timeout errors during document rendering
  • Missing artifact paths in output

Step 4: Fall Back to run_shell

If sandbox fails, use direct shell execution:

run_shell command="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 created successfully')
\""

Step 5: Verify Output

After generation, confirm the file exists:

run_shell command="ls -la output.pdf && file output.pdf"

Complete Example Workflow

1. Check libraries: run_shell "python -c \"import reportlab\""
2. Try sandbox: execute_code_sandbox with PDF generation code
3. If error detected: Fall back to run_shell with python -c
4. Verify: run_shell "ls -la *.pdf"
5. Read result: read_file filetype="pdf" file_path="output.pdf"

Error Handling Tips

  • Capture stderr from run_shell to diagnose issues
  • Use absolute paths when possible to avoid working directory issues
  • For complex documents, write the Python script to a file first, then execute
  • Consider installing missing libraries: run_shell command="pip install reportlab"

Library Alternatives

If reportlab is unavailable, try:

  • fpdf - Simpler API, good for basic PDFs
  • weasyprint - HTML/CSS to PDF conversion
  • pypdf - PDF manipulation and merging

Common Pitfalls

  • Don't assume sandbox errors mean the approach is wrong—often it's环境 issues
  • Always verify the PDF was created before proceeding
  • Handle encoding issues explicitly (use utf-8)
  • For images in PDFs, ensure image files are accessible to the execution context
자주 묻는 질문

AI는 샌드박스를 먼저 시도하나요?

네, 가이드는 반복 작업에 더 깔끔하므로 샌드박스를 먼저 시도하라고 말합니다.

실패의 신호는 무엇인가요?

일반적인 실행 실패 메시지, import 오류 및 그와 비슷한 불분명한 문제입니다.

어떤 라이브러리를 확인하나요?

가이드는 reportlab, fpdf, pypdf를 확인합니다.

상세 정보

작성자의 원본 설명

Reliable PDF generation using shell-based Python execution when sandbox fails

repo: HKUDS/AgentPilot

인기도

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

이 스킬이 유용한가요?

0

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

댓글

  • …

이 저장소의 다른 스킬

비슷한 스킬