[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M6HXG0D194AJYRG010W0PHYY":3,"skill-same:01M6HXG0D194AJYRG010W0PHYY":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":51,"repositoryHtmlUrl":52,"repositoryHomepageUrl":6,"ownerHtmlUrl":53,"ownerBlogUrl":54,"ownerDescription":6,"updatedAt":55,"install":56,"resources":69},"01M6HXG0D194AJYRG010W0PHYY","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","HKUDS\u002FAgentPilot","HKUDS","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F118165258?v=4","01M6HW8VRNZP64G0P4MVJW2KKQ","✨Data Intelligence Lab@HKU✨","01M6HW8VWZVHBRHYH3T330PFWV",8029,"MIT","https:\u002F\u002Fgithub.com\u002FHKUDS\u002FAgentPilot\u002Fblob\u002Fmain\u002Fopenspace\u002Flegacy\u002Fv1\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","6b84b0689ca0d9e7b1e4061188ff6b60758e0f8a","openspace\u002Flegacy\u002Fv1\u002Fgdpval_bench\u002Fskills\u002Fdirect-reportlab-pdf-generation",944,"https:\u002F\u002Fgithub.com\u002FHKUDS\u002FAgentPilot","https:\u002F\u002Fgithub.com\u002FHKUDS","https:\u002F\u002Fsites.google.com\u002Fview\u002Fchaoh","2026-11-12 22:26:39",{"source":8,"skillName":5,"commands":57,"prompt":67,"zipAvailable":68},[58,61,64],{"tool":59,"command":60},"npx","npx skills add HKUDS\u002FAgentPilot --skill direct-reportlab-pdf-generation",{"tool":62,"command":63},"bunx","bunx skills add HKUDS\u002FAgentPilot --skill direct-reportlab-pdf-generation",{"tool":65,"command":66},"pnpm","pnpm dlx skills add HKUDS\u002FAgentPilot --skill direct-reportlab-pdf-generation","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002FHKUDS\u002FAgentPilot\u002Fblob\u002Fmain\u002Fopenspace\u002Flegacy\u002Fv1\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\u002FHKUDS\u002FAgentPilot\u002Fblob\u002Fmain\u002Fopenspace\u002Flegacy\u002Fv1\u002Fgdpval_bench\u002Fskills\u002Fdirect-reportlab-pdf-generation\u002F.skill_id",[77,96,115,136,160,182],{"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},"01M6HYB297NDABRERJRVG0K8R0","agentpilot","Set up AgentPilot and use its single entry to prepare missing inputs and run configured RSI experiments. Use when the user requests AgentPilot installation or work with AgentPilot.","https:\u002F\u002Fgithub.com\u002FHKUDS\u002FAgentPilot\u002Fblob\u002Fmain\u002Fplugins\u002Fagentpilot\u002Fskills\u002Fagentpilot\u002FSKILL.md",[],[79,84,85,86,87,88,89,90,91,92,93,94,34,95],"prepare","requests","with","missing","installation","rsi","up","use","user","work","SET","experiments",{"skillNo":97,"name":98,"nameZh":6,"description":99,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":100,"categories":101,"keywords":102,"publishedAt":43},"01M6HYAYWXTTE1J7DJM0MFNQ4H","remember","Review auto-memory entries and propose promotions to OPENSPACE.md, OPENSPACE.local.md, or retained auto-memory topics; detect duplicates, stale facts, conflicts, and ambiguous entries before making changes.","https:\u002F\u002Fgithub.com\u002FHKUDS\u002FAgentPilot\u002Fblob\u002Fmain\u002Fopenspace\u002Fopenspace\u002Fskills\u002Fremember\u002FSKILL.md",[],[98,103,104,105,106,107,108,109,110,111,112,113,114],"memory","review","auto","openspace","changes","facts","detect","entries","local","conflicts","stale","duplicates",{"skillNo":116,"name":117,"nameZh":6,"description":118,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":119,"categories":120,"keywords":122,"publishedAt":43},"01M6HYAVMPM4SBDV60R2B5HPV8","skill-discovery","Search reusable OpenSpace skills locally, and browse cloud packages step by step when a cloud skill may help. Reusing proven skills saves tokens, improves reliability, and extends your capabilities beyond built-in tools.","https:\u002F\u002Fgithub.com\u002FHKUDS\u002FAgentPilot\u002Fblob\u002Fmain\u002Fopenspace\u002Fopenspace\u002Fhost_skills\u002Fskill-discovery\u002FSKILL.md",[121],{"categoryNo":24,"categoryName":25,"taxonomyType":21,"taxonomyTypeDesc":22},[123,124,125,106,126,127,128,129,130,131,132,133,134,135],"skill discovery","discovery","reusable","step by step","tokens","packages","help","cloud","reliability","capabilities","browse","search","Tools",{"skillNo":137,"name":138,"nameZh":6,"description":139,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":140,"categories":141,"keywords":143,"publishedAt":43},"01M6HYAR811B3RB0M50RBEDGN6","delegate-task","Delegate tasks to OpenSpace — a full-stack autonomous worker for coding, DevOps, web research, and desktop automation, backed by an extensive MCP tool and skill library. Skills auto-improve through use, reducing token consumption over time. A cloud community lets agents share and collectively evolve reusable skills.","https:\u002F\u002Fgithub.com\u002FHKUDS\u002FAgentPilot\u002Fblob\u002Fmain\u002Fopenspace\u002Fopenspace\u002Fhost_skills\u002Fdelegate-task\u002FSKILL.md",[142],{"categoryNo":24,"categoryName":25,"taxonomyType":21,"taxonomyTypeDesc":22},[144,145,146,106,147,148,149,150,151,125,105,91,152,153,154,155,156,157,158,159],"delegate","task","delegate task","time","improve","desktop automation","worker","community","autonomous","tool","stack","for","share","tasks","automation","MCP",{"skillNo":161,"name":162,"nameZh":6,"description":163,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":164,"categories":165,"keywords":166,"publishedAt":43},"01M6HYAM9FSGV6E52AYENDQXYH","write-special-chars-ts-check","Workaround for write_file failures caused by special characters (apostrophes, backticks, template literals) using a Python heredoc script, plus a reliable TypeScript type-checking step that filters output to only the newly-written files to avoid being misled by pre-existing errors.","https:\u002F\u002Fgithub.com\u002FHKUDS\u002FAgentPilot\u002Fblob\u002Fmain\u002Fopenspace\u002Flegacy\u002Fv1\u002Fshowcase\u002Fskills\u002Fwrite-special-chars-ts-check\u002FSKILL.md",[],[167,168,169,170,171,172,173,174,175,32,176,177,178,179,155,180,181],"write special chars ts check","write","check","type","files","filters","only","template","file","typescript","output","Existing","type-checking","errors","script",{"skillNo":183,"name":184,"nameZh":6,"description":185,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":186,"categories":187,"keywords":188,"publishedAt":43},"01M6HYAH05HGV7SVWSVR8PJRQD","write-special-chars-readback","Workaround for write_file failures caused by special characters (apostrophes, backticks, template literals) using a Python heredoc script, with mandatory post-write verification via read_file and cleanup of \u002Ftmp helper scripts.","https:\u002F\u002Fgithub.com\u002FHKUDS\u002FAgentPilot\u002Fblob\u002Fmain\u002Fopenspace\u002Flegacy\u002Fv1\u002Fshowcase\u002Fskills\u002Fwrite-special-chars-readback\u002FSKILL.md",[],[189,190,168,86,155,181,191,192,40,193,194,174,175,195,196,32],"write special chars readback","readback","helper","post","scripts","read","verification","cleanup"]