Aller au contenu
Skillpedia
PDF, Word et présentations7.8k · #12929

pdf-generation-troubleshooting

Ce qu’il fait

Ce skill est un plan en trois étapes pour créer un PDF, qui se replie de pandoc vers les bibliothèques Python. Il s'adresse aux personnes qui convertissent du Markdown ou construisent des PDF lorsque certains outils peuvent manquer.

Quand l’utiliser

  • ✓Quand j'ai un fichier Markdown ou HTML qui doit devenir un PDF.
  • ✓Quand pandoc est absent ou échoue lors de la conversion.
  • ✓Quand j'ai besoin d'un PDF construit de zéro avec Python parce que les autres outils ne sont pas disponibles.

Lien du skill

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

Copiez-le et collez-le dans votre IA (Claude, ChatGPT ou Cursor) en lui demandant de suivre les instructions.

Comment l’utiliser

Le plus simple : copiez le message et collez-le dans votre IA. Elle lit le skill et suit les instructions.

Message prêt à coller

Utilise ce skill pour m’aider : https://github.com/HKUDS/AgentPilot/blob/main/openspace/benchmarks/gdpval/skills/pdf-generation-troubleshooting/SKILL.md Lis le fichier SKILL.md de ce lien et suis ses instructions pour ma tâche.
Envie que votre IA trouve seule des skills comme celui-ci ?Installez le MCP gratuit de Skillpedia : une ligne, et elle cherche parmi 15 000+ skills avant chaque tâche.Installer en 1 minute →

Exemple de demande à votre IA

“Transforme ce Markdown en PDF. Si pandoc n'est pas disponible ici, utilise plutôt une bibliothèque Python.”

5 nouveaux skills par semaine. 1 minute de lecture.

Comment ça marche

L'IA vérifie la présence de pandoc et convertit si celui-ci est disponible. Sinon, elle vérifie reportlab et l'installe si nécessaire, puis essaie enfin fpdf2.

Contenu technique (SKILL.md original)

Texte original de l’auteur, en anglais, directement depuis 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
Questions fréquentes

Quel est le premier choix ?

Pandoc, qui est l'option la plus simple pour les fichiers Markdown ou HTML.

Que vient après pandoc ?

Reportlab, une bibliothèque Python, puis fpdf2 si reportlab ne fonctionne pas.

Les outils sont-ils vérifiés avant utilisation ?

Oui, chaque étape vérifie l'installation avant de s'exécuter.

Détails

Description originale de l’auteur

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

repo: HKUDS/AgentPilot

Popularité

Étoiles GitHub
7.8k
Position au classement
#12929
Licence
MIT
Mis à jour
01/11/2026

Ce skill vous est-il utile ?

0

Connectez-vous pour voter.

Commentaires

  • …

Autres skills de ce dépôt

Skills similaires