[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M6KFC3X96M7HGHFRB4PG97FN":3,"skill-same:01M6KFC3X96M7HGHFRB4PG97FN":76},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":16,"categories":17,"keywords":26,"publishedAt":43,"linkOnly":44,"markdownContent":45,"markdownBody":46,"frontMatter":47,"refName":48,"commitSha":49,"skillDirectory":50,"forksCount":14,"repositoryHtmlUrl":51,"repositoryHomepageUrl":6,"ownerHtmlUrl":52,"ownerBlogUrl":53,"ownerDescription":54,"updatedAt":55,"install":56,"resources":69},"01M6KFC3X96M7HGHFRB4PG97FN","direct-reportlab-pdf-generation",null,"Generate complex multi-page PDFs by running reportlab Python code directly via run_shell when shell_agent fails on document creation","xyliu-cs\u002FOpenSpace-GDPval","xyliu-cs","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F89236536?v=4","01M6KF8Z1V4TXS86CKSH48BY8T","xy","01M6KF8Z67443W0SHXM85JEF0B",0,"MIT","https:\u002F\u002Fgithub.com\u002Fxyliu-cs\u002FOpenSpace-GDPval\u002Fblob\u002Fmain\u002Fgdpval_bench\u002Fskills\u002Fdirect-reportlab-pdf-generation\u002FSKILL.md",[18,23],{"categoryNo":19,"categoryName":20,"taxonomyType":21,"taxonomyTypeDesc":22},"01JBSEEDCAT000000000000002","文档处理","SCENARIO","使用场景",{"categoryNo":24,"categoryName":25,"taxonomyType":21,"taxonomyTypeDesc":22},"01JBSEEDCAT000000000000023","Skill与智能体开发",[27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42],"PDF","direct","generation","pdf generation","direct reportlab pdf generation","python","generate","run","code","shell","page","document","creation","via","multi","python code","2026-11-10 10:12:30",false,"---\nname: direct-reportlab-pdf-generation\ndescription: Generate complex multi-page PDFs by running reportlab Python code directly via run_shell when shell_agent fails on document creation\n---\n\n# Direct ReportLab PDF Generation via run_shell\n\n## When to Use This Skill\n\nUse this pattern when:\n- You need to create a complex, multi-page PDF document with structured content\n- Delegating PDF generation to `shell_agent` fails or produces unreliable results\n- You need fine-grained control over PDF layout, styling, and pagination\n\n## Core Technique\n\nInstead 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.\n\n## Step-by-Step Instructions\n\n### Step 1: Prepare Your PDF Content\n\nOrganize your content into logical sections that will become pages or page groups:\n- Title page\n- Table of contents (optional)\n- Main content sections\n- Appendices or references\n\n### Step 2: Write the ReportLab Python Script\n\nCreate a Python script that uses these key reportlab components:\n\n```python\nfrom reportlab.lib import colors\nfrom reportlab.lib.pagesizes import letter\nfrom reportlab.lib.styles import getSampleStyleSheet, ParagraphStyle\nfrom reportlab.lib.units import inch\nfrom reportlab.platypus import SimpleDocTemplate, Paragraph, Spacer, Table, TableStyle, PageBreak, Image\nfrom reportlab.lib.enums import TA_CENTER, TA_LEFT, TA_JUSTIFY\n\ndef create_pdf(filename, content_data):\n    doc = SimpleDocTemplate(filename, pagesize=letter,\n                           rightMargin=72, leftMargin=72,\n                           topMargin=72, bottomMargin=72)\n    \n    story = []\n    styles = getSampleStyleSheet()\n    \n    # Custom styles\n    title_style = ParagraphStyle(\n        'CustomTitle',\n        parent=styles['Heading1'],\n        fontSize=24,\n        textColor=colors.HexColor('#1a1a1a'),\n        spaceAfter=30,\n        alignment=TA_CENTER\n    )\n    \n    heading_style = ParagraphStyle(\n        'CustomHeading',\n        parent=styles['Heading2'],\n        fontSize=16,\n        textColor=colors.HexColor('#2c3e50'),\n        spaceBefore=20,\n        spaceAfter=12\n    )\n    \n    body_style = ParagraphStyle(\n        'CustomBody',\n        parent=styles['Normal'],\n        fontSize=11,\n        leading=16,\n        alignment=TA_JUSTIFY\n    )\n    \n    # Build document content\n    for section in content_data:\n        if section['type'] == 'title':\n            story.append(Paragraph(section['text'], title_style))\n        elif section['type'] == 'heading':\n            story.append(Paragraph(section['text'], heading_style))\n        elif section['type'] == 'paragraph':\n            story.append(Paragraph(section['text'], body_style))\n            story.append(Spacer(1, 12))\n        elif section['type'] == 'table':\n            table = Table(section['data'], colWidths=section.get('col_widths'))\n            table.setStyle(TableStyle([\n                ('BACKGROUND', (0, 0), (-1, 0), colors.grey),\n                ('TEXTCOLOR', (0, 0), (-1, 0), colors.whitesmoke),\n                ('ALIGN', (0, 0), (-1, -1), 'CENTER'),\n                ('FONTNAME', (0, 0), (-1, 0), 'Helvetica-Bold'),\n                ('FONTSIZE', (0, 0), (-1, 0), 12),\n                ('BOTTOMPADDING', (0, 0), (-1, 0), 12),\n                ('BACKGROUND', (0, 1), (-1, -1), colors.beige),\n                ('GRID', (0, 0), (-1, -1), 1, colors.black),\n            ]))\n            story.append(table)\n            story.append(Spacer(1, 20))\n        elif section['type'] == 'pagebreak':\n            story.append(PageBreak())\n    \n    doc.build(story)\n```\n\n### Step 3: Execute via run_shell\n\nRun the Python script directly using `run_shell`:\n\n```bash\npython3 \u003C\u003C 'EOF'\n# Your complete reportlab script here\nfrom reportlab.lib import colors\nfrom reportlab.lib.pagesizes import letter\nfrom reportlab.lib.styles import getSampleStyleSheet, ParagraphStyle\nfrom reportlab.platypus import SimpleDocTemplate, Paragraph, Spacer, Table, TableStyle, PageBreak\n\n# ... rest of your script\nEOF\n```\n\nOr save to a file and execute:\n\n```bash\ncat > generate_pdf.py \u003C\u003C 'SCRIPT'\n# Your complete script\nSCRIPT\n\npython3 generate_pdf.py\n```\n\n### Step 4: Handle Complex Content\n\nFor lengthy documents, structure content as a data structure:\n\n```python\ndocument_sections = [\n    {'type': 'title', 'text': 'Document Title'},\n    {'type': 'pagebreak'},\n    {'type': 'heading', 'text': 'Section 1'},\n    {'type': 'paragraph', 'text': 'Content here...'},\n    {'type': 'heading', 'text': 'Section 2'},\n    {'type': 'table', 'data': [['Header1', 'Header2'], ['Row1-Col1', 'Row1-Col2']]},\n    {'type': 'pagebreak'},\n    # Continue for all sections\n]\n```\n\n### Step 5: Verify Output\n\nCheck that the PDF was created successfully:\n\n```bash\nls -la your_document.pdf\n# Optionally check page count\npdfinfo your_document.pdf 2>\u002Fdev\u002Fnull || echo \"PDF created, pdfinfo not available\"\n```\n\n## Common Patterns\n\n### Multi-Section Documents\nUse `PageBreak()` between major sections to ensure clean pagination.\n\n### Tables with Data\nStructure tabular data as nested lists:\n```python\ntable_data = [\n    ['Column 1', 'Column 2', 'Column 3'],\n    ['Value 1', 'Value 2', 'Value 3'],\n    ['Value 4', 'Value 5', 'Value 6'],\n]\n```\n\n### Styled Text\nCreate custom `ParagraphStyle` objects for consistent formatting across sections.\n\n### Long Paragraphs\nReportLab automatically handles text wrapping. For very long content, consider breaking into multiple paragraphs.\n\n## Troubleshooting\n\n| Issue | Solution |\n|-------|----------|\n| Import errors | Ensure reportlab is installed: `pip install reportlab` |\n| Layout issues | Adjust margins in `SimpleDocTemplate` constructor |\n| Text overflow | Use `Spacer` elements to add vertical space |\n| Table width problems | Set explicit `colWidths` parameter |\n| Page breaks in wrong places | Insert `PageBreak()` explicitly before new sections |\n\n## Advantages Over shell_agent\n\n- **Deterministic**: Code executes exactly as written\n- **Debuggable**: Errors are immediate and clear\n- **Controllable**: Full access to reportlab's API\n- **Reliable**: No intermediate agent interpretation layer\n- **Efficient**: Single execution, no retry loops","# Direct ReportLab PDF Generation via run_shell\n\n## When to Use This Skill\n\nUse this pattern when:\n- You need to create a complex, multi-page PDF document with structured content\n- Delegating PDF generation to `shell_agent` fails or produces unreliable results\n- You need fine-grained control over PDF layout, styling, and pagination\n\n## Core Technique\n\nInstead 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.\n\n## Step-by-Step Instructions\n\n### Step 1: Prepare Your PDF Content\n\nOrganize your content into logical sections that will become pages or page groups:\n- Title page\n- Table of contents (optional)\n- Main content sections\n- Appendices or references\n\n### Step 2: Write the ReportLab Python Script\n\nCreate a Python script that uses these key reportlab components:\n\n```python\nfrom reportlab.lib import colors\nfrom reportlab.lib.pagesizes import letter\nfrom reportlab.lib.styles import getSampleStyleSheet, ParagraphStyle\nfrom reportlab.lib.units import inch\nfrom reportlab.platypus import SimpleDocTemplate, Paragraph, Spacer, Table, TableStyle, PageBreak, Image\nfrom reportlab.lib.enums import TA_CENTER, TA_LEFT, TA_JUSTIFY\n\ndef create_pdf(filename, content_data):\n    doc = SimpleDocTemplate(filename, pagesize=letter,\n                           rightMargin=72, leftMargin=72,\n                           topMargin=72, bottomMargin=72)\n    \n    story = []\n    styles = getSampleStyleSheet()\n    \n    # Custom styles\n    title_style = ParagraphStyle(\n        'CustomTitle',\n        parent=styles['Heading1'],\n        fontSize=24,\n        textColor=colors.HexColor('#1a1a1a'),\n        spaceAfter=30,\n        alignment=TA_CENTER\n    )\n    \n    heading_style = ParagraphStyle(\n        'CustomHeading',\n        parent=styles['Heading2'],\n        fontSize=16,\n        textColor=colors.HexColor('#2c3e50'),\n        spaceBefore=20,\n        spaceAfter=12\n    )\n    \n    body_style = ParagraphStyle(\n        'CustomBody',\n        parent=styles['Normal'],\n        fontSize=11,\n        leading=16,\n        alignment=TA_JUSTIFY\n    )\n    \n    # Build document content\n    for section in content_data:\n        if section['type'] == 'title':\n            story.append(Paragraph(section['text'], title_style))\n        elif section['type'] == 'heading':\n            story.append(Paragraph(section['text'], heading_style))\n        elif section['type'] == 'paragraph':\n            story.append(Paragraph(section['text'], body_style))\n            story.append(Spacer(1, 12))\n        elif section['type'] == 'table':\n            table = Table(section['data'], colWidths=section.get('col_widths'))\n            table.setStyle(TableStyle([\n                ('BACKGROUND', (0, 0), (-1, 0), colors.grey),\n                ('TEXTCOLOR', (0, 0), (-1, 0), colors.whitesmoke),\n                ('ALIGN', (0, 0), (-1, -1), 'CENTER'),\n                ('FONTNAME', (0, 0), (-1, 0), 'Helvetica-Bold'),\n                ('FONTSIZE', (0, 0), (-1, 0), 12),\n                ('BOTTOMPADDING', (0, 0), (-1, 0), 12),\n                ('BACKGROUND', (0, 1), (-1, -1), colors.beige),\n                ('GRID', (0, 0), (-1, -1), 1, colors.black),\n            ]))\n            story.append(table)\n            story.append(Spacer(1, 20))\n        elif section['type'] == 'pagebreak':\n            story.append(PageBreak())\n    \n    doc.build(story)\n```\n\n### Step 3: Execute via run_shell\n\nRun the Python script directly using `run_shell`:\n\n```bash\npython3 \u003C\u003C 'EOF'\n# Your complete reportlab script here\nfrom reportlab.lib import colors\nfrom reportlab.lib.pagesizes import letter\nfrom reportlab.lib.styles import getSampleStyleSheet, ParagraphStyle\nfrom reportlab.platypus import SimpleDocTemplate, Paragraph, Spacer, Table, TableStyle, PageBreak\n\n# ... rest of your script\nEOF\n```\n\nOr save to a file and execute:\n\n```bash\ncat > generate_pdf.py \u003C\u003C 'SCRIPT'\n# Your complete script\nSCRIPT\n\npython3 generate_pdf.py\n```\n\n### Step 4: Handle Complex Content\n\nFor lengthy documents, structure content as a data structure:\n\n```python\ndocument_sections = [\n    {'type': 'title', 'text': 'Document Title'},\n    {'type': 'pagebreak'},\n    {'type': 'heading', 'text': 'Section 1'},\n    {'type': 'paragraph', 'text': 'Content here...'},\n    {'type': 'heading', 'text': 'Section 2'},\n    {'type': 'table', 'data': [['Header1', 'Header2'], ['Row1-Col1', 'Row1-Col2']]},\n    {'type': 'pagebreak'},\n    # Continue for all sections\n]\n```\n\n### Step 5: Verify Output\n\nCheck that the PDF was created successfully:\n\n```bash\nls -la your_document.pdf\n# Optionally check page count\npdfinfo your_document.pdf 2>\u002Fdev\u002Fnull || echo \"PDF created, pdfinfo not available\"\n```\n\n## Common Patterns\n\n### Multi-Section Documents\nUse `PageBreak()` between major sections to ensure clean pagination.\n\n### Tables with Data\nStructure tabular data as nested lists:\n```python\ntable_data = [\n    ['Column 1', 'Column 2', 'Column 3'],\n    ['Value 1', 'Value 2', 'Value 3'],\n    ['Value 4', 'Value 5', 'Value 6'],\n]\n```\n\n### Styled Text\nCreate custom `ParagraphStyle` objects for consistent formatting across sections.\n\n### Long Paragraphs\nReportLab automatically handles text wrapping. For very long content, consider breaking into multiple paragraphs.\n\n## Troubleshooting\n\n| Issue | Solution |\n|-------|----------|\n| Import errors | Ensure reportlab is installed: `pip install reportlab` |\n| Layout issues | Adjust margins in `SimpleDocTemplate` constructor |\n| Text overflow | Use `Spacer` elements to add vertical space |\n| Table width problems | Set explicit `colWidths` parameter |\n| Page breaks in wrong places | Insert `PageBreak()` explicitly before new sections |\n\n## Advantages Over shell_agent\n\n- **Deterministic**: Code executes exactly as written\n- **Debuggable**: Errors are immediate and clear\n- **Controllable**: Full access to reportlab's API\n- **Reliable**: No intermediate agent interpretation layer\n- **Efficient**: Single execution, no retry loops",{"name":5,"description":7},"main","af1b40a42167d09c30b3a63000aa14ace4c1e229","gdpval_bench\u002Fskills\u002Fdirect-reportlab-pdf-generation","https:\u002F\u002Fgithub.com\u002Fxyliu-cs\u002FOpenSpace-GDPval","https:\u002F\u002Fgithub.com\u002Fxyliu-cs","https:\u002F\u002Fxyliu-cs.github.io","PhD Student in CS, CUHK-Shenzhen.","2026-04-06 20:32:15",{"source":8,"skillName":5,"commands":57,"prompt":67,"zipAvailable":68},[58,61,64],{"tool":59,"command":60},"npx","npx skills add xyliu-cs\u002FOpenSpace-GDPval --skill direct-reportlab-pdf-generation",{"tool":62,"command":63},"bunx","bunx skills add xyliu-cs\u002FOpenSpace-GDPval --skill direct-reportlab-pdf-generation",{"tool":65,"command":66},"pnpm","pnpm dlx skills add xyliu-cs\u002FOpenSpace-GDPval --skill direct-reportlab-pdf-generation","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002Fxyliu-cs\u002FOpenSpace-GDPval\u002Fblob\u002Fmain\u002Fgdpval_bench\u002Fskills\u002Fdirect-reportlab-pdf-generation\u002FSKILL.md",true,[70],{"path":71,"resourceType":72,"resourceTypeDesc":73,"sizeBytes":74,"sourceHtmlUrl":75},".skill_id","OTHER","其他",45,"https:\u002F\u002Fgithub.com\u002Fxyliu-cs\u002FOpenSpace-GDPval\u002Fblob\u002Fmain\u002Fgdpval_bench\u002Fskills\u002Fdirect-reportlab-pdf-generation\u002F.skill_id",[77,90,98,114,139,156],{"skillNo":78,"name":79,"nameZh":6,"description":80,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":81,"categories":82,"keywords":83,"publishedAt":43},"01M6KG8MF1S664SWBDENYRSCK8","zip-export-deliverable","Ensures codebase deliverables are properly exported as ZIP archives through a dedicated finalization step","https:\u002F\u002Fgithub.com\u002Fxyliu-cs\u002FOpenSpace-GDPval\u002Fblob\u002Fmain\u002Fgdpval_bench\u002Fskills\u002Fzip-export-deliverable\u002FSKILL.md",[],[84,85,86,87,88,89],"zip export deliverable","zip","export","deliverables","codebase","as",{"skillNo":91,"name":92,"nameZh":6,"description":93,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":94,"categories":95,"keywords":96,"publishedAt":43},"01M6KG8GAZWHHEK7VNJDW0ME21","zip-deliverable-finalization","Ensure codebase deliverables are properly packaged as ZIP exports in a dedicated final step","https:\u002F\u002Fgithub.com\u002Fxyliu-cs\u002FOpenSpace-GDPval\u002Fblob\u002Fmain\u002Fgdpval_bench\u002Fskills\u002Fzip-deliverable-finalization\u002FSKILL.md",[],[97,85,87,88,89],"zip deliverable finalization",{"skillNo":99,"name":100,"nameZh":6,"description":101,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":102,"categories":103,"keywords":104,"publishedAt":43},"01M6KG8CMQQ1PYMNTSRZ9VS1MD","zero-iteration-failure-analysis","Identify and handle agent failures with 0 iterations as pre-execution system issues","https:\u002F\u002Fgithub.com\u002Fxyliu-cs\u002FOpenSpace-GDPval\u002Fblob\u002Fmain\u002Fgdpval_bench\u002Fskills\u002Fzero-iteration-failure-analysis\u002FSKILL.md",[],[105,106,107,108,109,110,111,112,89,113],"failure analysis","ZeRO","analysis","iteration","zero iteration failure analysis","with","issues","execution","system",{"skillNo":115,"name":116,"nameZh":6,"description":117,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":118,"categories":119,"keywords":125,"publishedAt":43},"01M6KG86W3PA07FT9W58YHHERM","write-file-fallback-report","Generate professional documents using write_file when primary data sources fail, leveraging embedded domain knowledge instead of external retrieval","https:\u002F\u002Fgithub.com\u002Fxyliu-cs\u002FOpenSpace-GDPval\u002Fblob\u002Fmain\u002Fgdpval_bench\u002Fskills\u002Fwrite-file-fallback-report\u002FSKILL.md",[120],{"categoryNo":121,"categoryName":122,"taxonomyType":123,"taxonomyTypeDesc":124},"01JBSEEDCAT000000000000034","行政与办公人员","PROFESSION","适用职业",[126,127,128,129,130,131,132,133,134,33,135,136,137,138],"fallback","write","file","report","write file fallback report","domain","professional","sources","retrieval","embedded","documents","data","knowledge",{"skillNo":140,"name":141,"nameZh":6,"description":142,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":143,"categories":144,"keywords":146,"publishedAt":43},"01M6KG82GAEY3GG77CMGCK1C2T","fallback-doc-with-delegation","Generate professional documents after tool failures using shell_agent for complex formats or write_file for simple text\u002Fmarkdown","https:\u002F\u002Fgithub.com\u002Fxyliu-cs\u002FOpenSpace-GDPval\u002Fblob\u002Fmain\u002Fgdpval_bench\u002Fskills\u002Fwrite-file-fallback-report-enhanced\u002FSKILL.md",[145],{"categoryNo":24,"categoryName":25,"taxonomyType":21,"taxonomyTypeDesc":22},[147,110,126,148,149,36,136,33,128,150,151,152,127,153,132,154,155],"fallback doc with delegation","doc","delegation","markdown","tool","text","simple","formats","for",{"skillNo":157,"name":158,"nameZh":6,"description":159,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":160,"categories":161,"keywords":163,"publishedAt":43},"01M6KG7WT7GX5NYCGEFHW22NV7","context-anchored-fallback-report","Generate documents with write_file when retrieval tools fail, with explicit guardrails against task context drift","https:\u002F\u002Fgithub.com\u002Fxyliu-cs\u002FOpenSpace-GDPval\u002Fblob\u002Fmain\u002Fgdpval_bench\u002Fskills\u002Fwrite-file-fallback-report-enhanced-4bc5c2\u002FSKILL.md",[162],{"categoryNo":121,"categoryName":122,"taxonomyType":123,"taxonomyTypeDesc":124},[126,129,164,165,33,128,166,167,127,168,169,134,110,170,136],"context","context anchored fallback report","Guardrails","Tools","task","drift","context drift"]