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

reportlab-styles

하는 일

이 스킬은 PDF를 만들 때 ReportLab 라이브러리의 기본 제공 단락 스타일을 쓰는 방법을 설명합니다. Python으로 PDF 문서를 만들다가 스타일 오류를 겪는 사람에게 맞습니다.

사용하는 경우

  • ✓ReportLab 스크립트가 단락 스타일 이름에서 KeyError를 낼 때.
  • ✓스타일 이름을 직접 만들지 않고 제목과 본문에 스타일을 적용하고 싶은 경우.
  • ✓샘플 스타일의 기본 모양으로 PDF 보고서를 만들고 싶을 때.

스킬 링크

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

AI에게 요청하는 예시

“제 ReportLab 스크립트가 스타일에서 KeyError로 멈춥니다. 내장 스타일을 써서 고쳐 주세요.”

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

작동 방식

에이전트는 ReportLab의 샘플 스타일시트를 가져와 Title, Heading1, Normal 같은 기존 스타일 이름을 씁니다. 이미 있는 이름으로 새 스타일을 만들지 않습니다.

기술 내용 (원본 SKILL.md)

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

ReportLab Pre-Defined Styles Reference

Overview

ReportLab's reportlab.lib.styles.getSampleStyleSheet() provides a collection of pre-defined paragraph styles. Use these existing styles rather than redefining them to avoid KeyError exceptions.

Available Pre-Defined Styles

The standard stylesheet includes these commonly-used styles:

Style Name Purpose
Normal Default body text
Title Document title (large, bold)
Heading1 Level 1 section heading
Heading2 Level 2 section heading
Heading3 Level 3 section heading
Heading4 Level 4 section heading
Heading5 Level 5 section heading
Heading6 Level 6 section heading
Bullet Bulleted list items
Definition Definition list terms
Italic Italicized text
Code Monospace code text

Correct Usage Pattern

from reportlab.lib.styles import getSampleStyleSheet
from reportlab.platypus import Paragraph

# Get the stylesheet
styles = getSampleStyleSheet()

# Use existing styles directly (CORRECT)
title = Paragraph("My Document Title", styles['Title'])
heading = Paragraph("Section Header", styles['Heading1'])
body = Paragraph("Regular text content", styles['Normal'])

Common Mistake to Avoid

# WRONG - Don't redefine existing style names
from reportlab.lib.styles import getSampleStyleSheet, ParagraphStyle

styles = getSampleStyleSheet()

# This will cause KeyError when you try to use 'Title' later
styles.add(ParagraphStyle(
    name='Title',  # Overwrites the pre-defined 'Title' style
    fontSize=24,
    # ... incomplete definition
))

# Later code expecting the full 'Title' style will fail
paragraph = Paragraph("Title Text", styles['Title'])  # KeyError!

Best Practices

  1. Use existing styles as-is when they meet your needs
  2. Create new style names for custom styles (e.g., MyCustomTitle, CustomHeading)
  3. Base custom styles on existing ones when you need modifications:
from reportlab.lib.styles import getSampleStyleSheet, ParagraphStyle

styles = getSampleStyleSheet()

# Create a NEW style with a unique name
custom_title = ParagraphStyle(
    name='CustomTitle',  # Unique name, doesn't conflict
    parent=styles['Title'],  # Base it on existing Title
    fontSize=28,
    spaceAfter=30
)
styles.add(custom_title)

# Now both styles are available
styles['Title']       # Original pre-defined style
styles['CustomTitle'] # Your custom variant

Quick Reference Checklist

  • Import getSampleStyleSheet() from reportlab.lib.styles
  • Call styles = getSampleStyleSheet() once at the start
  • Access styles via styles['StyleName'] (case-sensitive)
  • Do NOT add styles with names that already exist in the stylesheet
  • Use unique names for any custom styles you create
  • Common available styles: Normal, Title, Heading1-6, Bullet, Code, Italic
자주 묻는 질문

어떤 스타일이 기본 제공되나요?

Normal, Title, Heading1부터 Heading6까지, Bullet, Definition, Italic, Code를 나열합니다.

KeyError는 무엇 때문에 생기나요?

스킬은 기존 스타일 이름을 다시 정의하는 것 때문에 생긴다고 설명하므로, 해결책은 내장 이름을 쓰는 것입니다.

디자인에 새 스타일이 필요하나요?

스킬은 먼저 기존 스타일을 쓰고, 새 스타일은 고유한 이름으로만 추가하라고 제안합니다.

상세 정보

작성자의 원본 설명

Use reportlab's pre-defined styles from getSampleStyleSheet() correctly

repo: HKUDS/AgentPilot

인기도

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

이 스킬이 유용한가요?

0

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

댓글

  • …

이 저장소의 다른 스킬

비슷한 스킬