Pular para o conteúdo
Skillpedia
PDF, Word e slides7,8 mil · #12970

reportlab-styles

O que ela faz

Esta skill explica como usar os estilos de parágrafo prontos da biblioteca ReportLab para PDFs. É para pessoas que criam documentos PDF com Python e encontram erros de estilo.

Quando usar

  • ✓Quando um script ReportLab gera um KeyError em um nome de estilo de parágrafo.
  • ✓Quando você quer títulos e texto corrido estilizados sem criar nomes de estilo manualmente.
  • ✓Quando você monta um relatório em PDF e quer o visual padrão dos estilos de exemplo.

Link da skill

https://github.com/HKUDS/AgentPilot/blob/main/openspace/benchmarks/gdpval/skills/reportlab-styles/SKILL.md

Copie e cole na sua IA (Claude, ChatGPT ou Cursor) pedindo para seguir as instruções.

Como usar

O jeito mais fácil: copie a mensagem e cole na sua IA. Ela lê a skill e segue as instruções.

Mensagem pronta para colar

Use esta skill para me ajudar: https://github.com/HKUDS/AgentPilot/blob/main/openspace/benchmarks/gdpval/skills/reportlab-styles/SKILL.md Leia o arquivo SKILL.md desse link e siga as instruções dele na minha tarefa.
Quer que a sua IA encontre skills como esta sozinha?Instale o MCP grátis do Skillpedia: uma linha, e ela pesquisa entre 15.000+ skills antes de cada tarefa.Instalar em 1 minuto →

Exemplo do que pedir para a IA

“Meu script do ReportLab trava com um KeyError no estilo. Corrija usando os estilos já existentes.”

5 skills novas por semana. 1 minuto de leitura.

Como funciona

O agente obtém a folha de estilos de exemplo do ReportLab e usa os nomes de estilo existentes, como Title, Heading1 e Normal. Evita criar um estilo com um nome que já existe na folha.

Conteúdo técnico (SKILL.md original)

Texto original do autor, em inglês, direto do 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
Perguntas frequentes

Quais estilos já vêm prontos?

A skill lista Normal, Title, Heading1 a Heading6, Bullet, Definition, Italic e Code.

O que causa o KeyError?

A skill diz que o erro vem de redefinir um nome de estilo existente, então a correção é usar o nome pronto.

Preciso de um estilo novo para o meu design?

A skill sugere usar primeiro os estilos existentes e acrescentar novos apenas com nomes exclusivos.

Detalhes

Descrição original do autor

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

repo: HKUDS/AgentPilot

Popularidade

Estrelas no GitHub
7,8 mil
Posição no ranking
#12970
Licença
MIT
Atualizada em
01/11/2026

Essa skill é útil?

0

Entre para votar.

Comentários

  • …

Mais skills deste repositório

Skills parecidas