direct-reportlab-pdf-generation
यह क्या करती है
यह स्किल AI को दिखाती है कि ReportLab कोड लिखकर और चलाकर सटीक लेआउट वाली PDF कैसे बनाएँ। यह उन लोगों के लिए है जिन्हें कई पन्नों की रिपोर्ट या संरचित दस्तावेज़ PDF में चाहिए।
कब इस्तेमाल करें
- ✓जब मुझे शीर्षक, टेबल, इमेज और पेज ब्रेक वाली लंबी PDF चाहिए।
- ✓जब कोई सहायक एजेंट बार-बार मेरा PDF दस्तावेज़ नहीं बना पा रहा हो।
- ✓जब मुझे PDF का लेआउट बारीकी से नियंत्रित करना हो।
Skill का लिंक
https://github.com/HKUDS/AgentPilot/blob/main/openspace/benchmarks/gdpval/skills/direct-reportlab-pdf-generation/SKILL.mdइसे कॉपी करके अपने AI (Claude, ChatGPT या Cursor) में पेस्ट करें और निर्देशों का पालन करने को कहें।
कैसे इस्तेमाल करें
सबसे आसान तरीका: मैसेज कॉपी करके अपने AI में पेस्ट करें। वह skill पढ़कर निर्देशों का पालन करेगा।
पेस्ट करने के लिए तैयार मैसेज
Claude Code, Codex या Cursor के लिए: प्रोजेक्ट फ़ोल्डर में चलाएँ और skill इंस्टॉल हो जाएगी।
SKILL.md डाउनलोड करें और अपने एजेंट के skills फ़ोल्डर में रखें।
AI से क्या माँगें: उदाहरण
“मुझे ReportLab से एक कई पन्नों वाली PDF रिपोर्ट चाहिए, जिसमें शीर्षक पेज, टेबल और सेक्शन हों। क्या आप इसे बना सकते हैं?”
हर हफ़्ते 5 नई skills, 1 मिनट में पढ़ें।
यह कैसे काम करती है
AI सामग्री को सेक्शन में बाँटता है, ReportLab लाइब्रेरी का उपयोग करते हुए Python स्क्रिप्ट लिखता है, और PDF फ़ाइल बनाने के लिए उसे चलाता है।
तकनीकी सामग्री (मूल SKILL.md)
लेखक का मूल टेक्स्ट, अंग्रेज़ी में, सीधे GitHub से।
Direct ReportLab PDF Generation via run_shell
When to Use This Skill
Use this pattern when:
- You need to create a complex, multi-page PDF document with structured content
- Delegating PDF generation to
shell_agentfails or produces unreliable results - You need fine-grained control over PDF layout, styling, and pagination
Core Technique
Instead of asking shell_agent to handle PDF creation, write inline Python code using the reportlab library and execute it directly via run_shell. This gives you deterministic control over the document structure.
Step-by-Step Instructions
Step 1: Prepare Your PDF Content
Organize your content into logical sections that will become pages or page groups:
- Title page
- Table of contents (optional)
- Main content sections
- Appendices or references
Step 2: Write the ReportLab Python Script
Create a Python script that uses these key reportlab components:
from reportlab.lib import colors
from reportlab.lib.pagesizes import letter
from reportlab.lib.styles import getSampleStyleSheet, ParagraphStyle
from reportlab.lib.units import inch
from reportlab.platypus import SimpleDocTemplate, Paragraph, Spacer, Table, TableStyle, PageBreak, Image
from reportlab.lib.enums import TA_CENTER, TA_LEFT, TA_JUSTIFY
def create_pdf(filename, content_data):
doc = SimpleDocTemplate(filename, pagesize=letter,
rightMargin=72, leftMargin=72,
topMargin=72, bottomMargin=72)
story = []
styles = getSampleStyleSheet()
# Custom styles
title_style = ParagraphStyle(
'CustomTitle',
parent=styles['Heading1'],
fontSize=24,
textColor=colors.HexColor('#1a1a1a'),
spaceAfter=30,
alignment=TA_CENTER
)
heading_style = ParagraphStyle(
'CustomHeading',
parent=styles['Heading2'],
fontSize=16,
textColor=colors.HexColor('#2c3e50'),
spaceBefore=20,
spaceAfter=12
)
body_style = ParagraphStyle(
'CustomBody',
parent=styles['Normal'],
fontSize=11,
leading=16,
alignment=TA_JUSTIFY
)
# Build document content
for section in content_data:
if section['type'] == 'title':
story.append(Paragraph(section['text'], title_style))
elif section['type'] == 'heading':
story.append(Paragraph(section['text'], heading_style))
elif section['type'] == 'paragraph':
story.append(Paragraph(section['text'], body_style))
story.append(Spacer(1, 12))
elif section['type'] == 'table':
table = Table(section['data'], colWidths=section.get('col_widths'))
table.setStyle(TableStyle([
('BACKGROUND', (0, 0), (-1, 0), colors.grey),
('TEXTCOLOR', (0, 0), (-1, 0), colors.whitesmoke),
('ALIGN', (0, 0), (-1, -1), 'CENTER'),
('FONTNAME', (0, 0), (-1, 0), 'Helvetica-Bold'),
('FONTSIZE', (0, 0), (-1, 0), 12),
('BOTTOMPADDING', (0, 0), (-1, 0), 12),
('BACKGROUND', (0, 1), (-1, -1), colors.beige),
('GRID', (0, 0), (-1, -1), 1, colors.black),
]))
story.append(table)
story.append(Spacer(1, 20))
elif section['type'] == 'pagebreak':
story.append(PageBreak())
doc.build(story)
Step 3: Execute via run_shell
Run the Python script directly using run_shell:
python3 << 'EOF'
# Your complete reportlab script here
from reportlab.lib import colors
from reportlab.lib.pagesizes import letter
from reportlab.lib.styles import getSampleStyleSheet, ParagraphStyle
from reportlab.platypus import SimpleDocTemplate, Paragraph, Spacer, Table, TableStyle, PageBreak
# ... rest of your script
EOF
Or save to a file and execute:
cat > generate_pdf.py << 'SCRIPT'
# Your complete script
SCRIPT
python3 generate_pdf.py
Step 4: Handle Complex Content
For lengthy documents, structure content as a data structure:
document_sections = [
{'type': 'title', 'text': 'Document Title'},
{'type': 'pagebreak'},
{'type': 'heading', 'text': 'Section 1'},
{'type': 'paragraph', 'text': 'Content here...'},
{'type': 'heading', 'text': 'Section 2'},
{'type': 'table', 'data': [['Header1', 'Header2'], ['Row1-Col1', 'Row1-Col2']]},
{'type': 'pagebreak'},
#
अक्सर पूछे जाने वाले सवाल
ReportLab क्या है?
यह PDF फ़ाइलें बनाने की Python लाइब्रेरी है, जिसमें टेक्स्ट, टेबल और इमेज डाले जा सकते हैं।
क्या मुझे Python आना चाहिए?
स्किल में उदाहरण कोड है, लेकिन उसे चलाने के लिए Python और ReportLab लाइब्रेरी इंस्टॉल होनी चाहिए।
क्या विषय-सूची शामिल है?
सामग्री योजना में विषय-सूची वैकल्पिक बताई गई है।
जानकारी
लेखक का मूल विवरण
Generate complex multi-page PDFs by running reportlab Python code directly via run_shell when shell_agent fails on document creation
repo: HKUDS/AgentPilot
लोकप्रियता
- GitHub स्टार
- 7.8k
- रैंकिंग में स्थान
- #12855
- लाइसेंस
- MIT
- अपडेट की गई
- 1/11/2026
कमेंट
- …
इस repository की और skills
agentpilot
7.8kआपके एजेंट को AgentPilot से प्रोजेक्ट को चरण-दर-चरण सुधारने में मदद करती है, जिसमें बदलाव सुझाए, परखे और स्कोर किए जाते हैं।
openspace
7.8kआपके एजेंट को OpenSpace सेट करने में मदद करती है, जो एजेंट स्किल्स सहेजता और वापस लाता है, और MCP के ज़रिए आपके AI ऐप से जुड़ता है।
rsi-arena
7.8kआपके एजेंट को AIME और Terminal-Bench जैसे मानक AI बेंचमार्क टेस्ट सेट करने और चलाने में मदद करती है, ताकि सुधार के तरीकों की तुलना हो सके।
experiment-guide
7.8kआपके एजेंट को छोटे प्रयोग बनाने, उनके नतीजे पढ़ने और जाँच के दौरान उपयोगी निष्कर्ष लिखने में मदद करती है।
मिलती-जुलती skills
feishu-doc
394kयह आपके एजेंट को document टूल से Feishu क्लाउड दस्तावेज़ पढ़ने, बनाने और बदलने में मदद करती है, जिसमें टेक्स्ट, इमेज और टेबल शामिल हैं।
feishu-drive
394kयह आपके एजेंट को बॉट के साथ साझा किए गए Feishu क्लाउड फ़ोल्डर में फ़ाइलें देखने, व्यवस्थित करने और उन पर टिप्पणी करने देती है।
feishu-perm
394kयह आपके एजेंट को Feishu फ़ाइल तक किसकी पहुंच है, यह जांचने और बदलने देती है, और आपके अनुरोध के लिए सबसे छोटी अनुमति चुनती है।