reportlab-styles
Skill này làm gì
Skill này giải thích cách dùng các style đoạn văn có sẵn trong thư viện ReportLab cho PDF. Nó dành cho những người tạo tài liệu PDF bằng Python và gặp lỗi về style.
Khi nào nên dùng
- ✓Khi một script ReportLab báo KeyError với tên style đoạn văn.
- ✓Khi bạn muốn tiêu đề và nội dung được định dạng mà không phải tự tạo tên style mới.
- ✓Khi bạn tạo báo cáo PDF và muốn giao diện chuẩn của các style mẫu.
Liên kết skill
https://github.com/HKUDS/AgentPilot/blob/main/openspace/benchmarks/gdpval/skills/reportlab-styles/SKILL.mdSao chép rồi dán vào AI của bạn (Claude, ChatGPT hoặc Cursor) và nhờ nó làm theo hướng dẫn.
Cách dùng
Cách dễ nhất: sao chép tin nhắn và dán vào AI của bạn. AI sẽ đọc skill và làm theo hướng dẫn.
Tin nhắn có sẵn để dán
Dành cho Claude Code, Codex hoặc Cursor: chạy lệnh trong thư mục dự án của bạn và skill sẽ được cài đặt.
Tải tệp SKILL.md về và thả vào thư mục skill của agent.
Ví dụ cách nhờ AI
“Script ReportLab của tôi bị lỗi KeyError ở style. Hãy sửa bằng các style có sẵn.”
5 skill mới mỗi tuần. Đọc chỉ 1 phút.
Cách hoạt động
Agent lấy bảng style mẫu từ ReportLab và dùng các tên style có sẵn như Title, Heading1 và Normal. Nó tránh tạo style mới với tên đã có trong bảng.
Nội dung kỹ thuật (SKILL.md gốc)
Lấy nguyên văn từ GitHub, do tác giả viết bằng tiếng Anh.
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
- Use existing styles as-is when they meet your needs
- Create new style names for custom styles (e.g.,
MyCustomTitle,CustomHeading) - 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()fromreportlab.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
Câu hỏi thường gặp
Những style nào có sẵn?
Skill liệt kê Normal, Title, Heading1 đến Heading6, Bullet, Definition, Italic và Code.
Điều gì gây ra KeyError?
Skill nói lỗi do định nghĩa lại một tên style đã có, nên cách sửa là dùng tên có sẵn.
Tôi có cần style mới cho thiết kế của mình không?
Skill gợi ý dùng các style có sẵn trước và chỉ thêm style mới với tên duy nhất.
Chi tiết
Mô tả gốc của tác giả
Use reportlab's pre-defined styles from getSampleStyleSheet() correctly
repo: HKUDS/AgentPilot
Độ phổ biến
- Sao GitHub
- 7.8k
- Vị trí xếp hạng
- #12970
- Giấy phép
- MIT
- Cập nhật
- 1/11/2026
Bình luận
- …
Thêm skill từ kho mã này
agentpilot
7.8kGiúp agent của bạn cải thiện dự án từng bước bằng cách chuẩn bị tác vụ và chạy vòng lặp AgentPilot, gồm đề xuất, kiểm thử và chấm điểm thay đổi.
openspace
7.8kGiúp agent của bạn thiết lập OpenSpace, công cụ lưu và lấy lại skill của agent, rồi kết nối nó với ứng dụng AI của bạn qua MCP.
rsi-arena
7.8kGiúp agent của bạn thiết lập và chạy các bài kiểm thử benchmark AI chuẩn, như AIME và Terminal-Bench, để so sánh các phương pháp cải tiến khác nhau.
experiment-guide
7.8kGiúp agent của bạn lên kế hoạch các thí nghiệm nhỏ, đọc kết quả và ghi lại phát hiện khi tìm cách cải thiện một chương trình.
Skill tương tự
feishu-doc
394kGiúp agent của bạn đọc, tạo và sửa tài liệu đám mây Feishu, gồm văn bản, hình ảnh và bảng, bằng công cụ tài liệu.
feishu-drive
394kCho phép agent của bạn duyệt, sắp xếp và bình luận các file trong một thư mục đám mây Feishu đã được chia sẻ với bot.
feishu-perm
394kGiúp agent của bạn kiểm tra và thay đổi ai có quyền truy cập một file Feishu, chọn quyền nhỏ nhất đáp ứng yêu cầu của bạn.