मुख्य सामग्री पर जाएँ
Skillpedia
PDF, Word और स्लाइड7.8k · #12970

reportlab-styles

यह क्या करती है

यह स्किल बताती है कि ReportLab लाइब्रेरी के तैयार पैराग्राफ़ स्टाइल PDF में कैसे इस्तेमाल करें। यह उन लोगों के लिए है जो Python से PDF दस्तावेज़ बनाते हैं और स्टाइल की एरर से परेशान होते हैं।

कब इस्तेमाल करें

  • ✓जब ReportLab स्क्रिप्ट किसी पैराग्राफ़ स्टाइल नाम पर KeyError दे।
  • ✓जब आप शीर्षक और मुख्य टेक्स्ट को हाथ से नए स्टाइल नाम बनाए बिना स्टाइल करना चाहें।
  • ✓जब आप PDF रिपोर्ट बनाएँ और नमूना स्टाइल का मानक रूप चाहें।

Skill का लिंक

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

इसे कॉपी करके अपने AI (Claude, ChatGPT या Cursor) में पेस्ट करें और निर्देशों का पालन करने को कहें।

कैसे इस्तेमाल करें

सबसे आसान तरीका: मैसेज कॉपी करके अपने AI में पेस्ट करें। वह skill पढ़कर निर्देशों का पालन करेगा।

पेस्ट करने के लिए तैयार मैसेज

इस skill से मेरी मदद करो: https://github.com/HKUDS/AgentPilot/blob/main/openspace/benchmarks/gdpval/skills/reportlab-styles/SKILL.md इस लिंक की SKILL.md फ़ाइल पढ़ो और मेरे काम में उसके निर्देशों का पालन करो।
क्या आप चाहते हैं कि आपका AI ऐसी skills खुद ढूँढे?मुफ़्त Skillpedia MCP इंस्टॉल करें: बस एक लाइन, और हर काम से पहले यह 15,000+ skills में खोजता है।1 मिनट में इंस्टॉल करें →

AI से क्या माँगें: उदाहरण

“मेरी ReportLab स्क्रिप्ट स्टाइल पर KeyError के साथ क्रैश हो रही है। अंतर्निहित स्टाइल इस्तेमाल करके इसे ठीक कीजिए।”

हर हफ़्ते 5 नई skills, 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
अपडेट की गई
1/11/2026

क्या यह skill काम की है?

0

लॉग इन करें वोट करने के लिए।

कमेंट

  • …

इस repository की और skills

मिलती-जुलती skills