Zum Inhalt springen
Skillpedia
PDF, Word & Folien7.8k · #12929

pdf-generation-troubleshooting

Was er macht

Dieser Skill ist ein dreistufiger Plan zur PDF-Erstellung, der von pandoc auf Python-Bibliotheken zurückgreift. Er richtet sich an Menschen, die Markdown umwandeln oder PDFs bauen und bei denen manche Werkzeuge fehlen könnten.

Wann du ihn nutzt

  • ✓Wenn ich eine Markdown- oder HTML-Datei in ein PDF umwandeln muss.
  • ✓Wenn pandoc fehlt oder bei der Umwandlung scheitert.
  • ✓Wenn ich ein PDF mit Python von Grund auf erstellen muss, weil die anderen Werkzeuge nicht verfügbar sind.

Link zum Skill

https://github.com/HKUDS/AgentPilot/blob/main/openspace/benchmarks/gdpval/skills/pdf-generation-troubleshooting/SKILL.md

Kopiere ihn und füge ihn in deine KI ein (Claude, ChatGPT oder Cursor) mit der Bitte, den Anweisungen zu folgen.

So nutzt du ihn

Am einfachsten: Kopiere die Nachricht und füge sie in deine KI ein. Sie liest den Skill und folgt den Anweisungen.

Fertige Nachricht zum Einfügen

Nutze diesen Skill, um mir zu helfen: https://github.com/HKUDS/AgentPilot/blob/main/openspace/benchmarks/gdpval/skills/pdf-generation-troubleshooting/SKILL.md Lies die SKILL.md unter diesem Link und folge ihren Anweisungen für meine Aufgabe.
Soll deine KI Skills wie diesen selbst finden?Installiere den kostenlosen Skillpedia-MCP: eine Zeile, und sie durchsucht vor jeder Aufgabe 15.000+ Skills.In 1 Minute installieren →

Beispielanfrage an deine KI

“Wandle dieses Markdown in ein PDF um. Wenn pandoc hier nicht verfügbar ist, nimm stattdessen eine Python-Bibliothek.”

5 neue Skills pro Woche. 1 Minute Lesezeit.

So funktioniert es

Die KI prüft, ob pandoc vorhanden ist, und wandelt um, wenn ja. Andernfalls prüft sie reportlab und installiert es bei Bedarf, und probiert schließlich fpdf2.

Technischer Inhalt (originale SKILL.md)

Originaltext des Autors, auf Englisch, direkt von GitHub.

PDF Generation Troubleshooting Workflow

This skill provides a systematic approach to generating PDFs when multiple tools may be unavailable. Follow this fallback sequence to ensure PDF generation succeeds.

Workflow Overview

  1. Try pandoc first (simplest for markdown/HTML conversion)
  2. Fallback to reportlab (Python library for programmatic PDFs)
  3. Fallback to fpdf2 (alternative Python PDF library)

Each step includes installation verification before execution.

Step 1: Attempt pandoc Conversion

Use pandoc for markdown or HTML to PDF conversion. Check availability first:

# Check if pandoc is available
which pandoc || echo "pandoc not found"

If available, convert:

pandoc input.md -o output.pdf

If pandoc fails or is unavailable, proceed to Step 2.

Step 2: Attempt reportlab

Check Installation

python3 -c "import reportlab" 2>/dev/null && echo "reportlab available" || echo "reportlab not found"

Install if Needed

pip install reportlab

Create PDF Script

Use write_file to create a Python script:

from reportlab.lib.pagesizes import letter
from reportlab.pdfgen import canvas

def create_pdf(filename, content):
    c = canvas.Canvas(filename, pagesize=letter)
    c.drawString(100, 750, content)
    c.save()

if __name__ == "__main__":
    create_pdf("output.pdf", "Your content here")

Execute Script

Use run_shell with proper directory context:

cd /path/to/working/directory && python3 script.py

If reportlab fails, proceed to Step 3.

Step 3: Attempt fpdf2

Check Installation

python3 -c "from fpdf import FPDF" 2>/dev/null && echo "fpdf2 available" || echo "fpdf2 not found"

Install if Needed

pip install fpdf2

Create PDF Script

from fpdf import FPDF

def create_pdf(filename, text):
    pdf = FPDF()
    pdf.add_page()
    pdf.set_font("Arial", size=12)
    pdf.cell(200, 10, txt=text, ln=True)
    pdf.output(filename)

if __name__ == "__main__":
    create_pdf("output.pdf", "Your content here")

Execute Script

cd /path/to/working/directory && python3 script.py

Decision Matrix

Tool Best For Limitations
pandoc Markdown/HTML conversion Requires external installation
reportlab Complex layouts, graphics Steeper learning curve
fpdf2 Simple text PDFs Limited formatting options

Error Handling Pattern

For each tool attempt:

  1. Check availability/installation
  2. Install if missing (pip install <package>)
  3. Create script using write_file
  4. Execute using run_shell with cd <dir> && <command>
  5. Verify output file exists
  6. If fails, move to next tool in sequence

Example Fallback Implementation

# Pseudocode for full workflow
if command -v pandoc >/dev/null 2>&1; then
    pandoc input.md -o output.pdf && exit 0
fi

if python3 -c "import reportlab" 2>/dev/null; then
    # Create and run reportlab script
    exit 0
fi

# Final fallback: fpdf2
pip install fpdf2
# Create and run fpdf2 script

Key Principles

  • Always verify tool availability before attempting use
  • Install on-demand when a tool is missing
  • Use write_file for script creation (ensures clean, versionable code)
  • Use run_shell with explicit directory context (cd <dir> && <cmd>)
  • Progressive fallback ensures at least one method succeeds
  • Verify output after each attempt before moving to next tool
Häufige Fragen

Was ist die erste Wahl?

Pandoc, die einfachste Option für Markdown- oder HTML-Dateien.

Was kommt nach pandoc?

Reportlab, eine Python-Bibliothek, und danach fpdf2, wenn reportlab nicht funktioniert.

Werden Werkzeuge vor der Nutzung geprüft?

Ja. Jeder Schritt prüft vor dem Ausführen, ob das Werkzeug installiert ist.

Details

Originalbeschreibung des Autors

Systematic fallback workflow for PDF generation through pandoc, reportlab, and fpdf2 with installation verification

repo: HKUDS/AgentPilot

Beliebtheit

GitHub-Sterne
7.8k
Platz im Ranking
#12929
Lizenz
MIT
Aktualisiert
1.11.2026

Ist dieser Skill nützlich?

0

Anmelden um abzustimmen.

Kommentare

  • …

Weitere Skills aus diesem Repository

Ähnliche Skills