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

pdf-extract-create-workflow

Ce qu’il fait

Ce skill couvre le cycle complet des PDF : obtenir un PDF, lire son texte et produire un nouveau PDF mis en forme avec reportlab. Il s'adresse aux personnes qui travaillent avec des PDF provenant de sites web ou de leurs propres fichiers et ont besoin d'un nouveau document en résultat.

Quand l’utiliser

  • ✓Quand le PDF se trouve sur un site web et doit d'abord être téléchargé.
  • ✓Quand j'ai besoin du texte d'un PDF, puis qu'un nouveau PDF doit être créé à partir de ce contenu.
  • ✓Quand le PDF est déjà sur mon ordinateur et que je n'ai besoin que des étapes d'extraction et de création d'un nouveau document.

Lien du skill

https://github.com/HKUDS/AgentPilot/blob/main/openspace/benchmarks/gdpval/skills/pdf-download-extract-fallback-enhanced-29b2f4/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-download-extract-fallback-enhanced-29b2f4/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

“Télécharge ce PDF à partir du lien, extrais son texte, puis crée-moi une nouvelle synthèse PDF structurée avec reportlab.”

5 nouveaux skills par semaine. 1 minute de lecture.

Comment ça marche

L'IA télécharge le fichier avec une requête de type navigateur, vérifie qu'il s'agit d'un vrai PDF, extrait le texte avec le meilleur outil disponible, puis crée un nouveau document à partir du contenu traité.

Contenu technique (SKILL.md original)

Texte original de l’auteur, en anglais, directement depuis GitHub.

PDF Extract and Create Workflow

This skill provides a complete PDF lifecycle workflow for acquiring PDF documents from web sources or local files, extracting their text content, AND generating new structured PDFs from processed data—with multiple fallback mechanisms throughout.

Overview

When working with PDFs, you may need to:

  1. Download PDFs from web sources (with anti-bot protection)
  2. Extract text content from PDFs (with fallback strategies)
  3. Generate new PDFs from processed data (with professional formatting)

This workflow ensures maximum success rate through progressive fallback strategies for extraction and templated approaches for generation.

Entry Point: Determine Your Starting Point

Before beginning, identify your scenario:

Scenario Start Here Skip
PDF already on local disk Step 2 (Verify File Type) Step 1 (Download)
PDF at a web URL Step 1 (Download) None
Need to CREATE a PDF from data Mode C (Generate) Modes A & B
Need to extract AND create Mode A/B → Mode C None

Mode A: Web URL Download

Step 1: Download PDF with Browser User-Agent

Many PDF hosting sites use JavaScript-based redirects or block automated requests. Use curl with a realistic browser user-agent:

curl -L -A "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36" -o output.pdf "URL_HERE"

Key flags:

  • -L: Follow redirects
  • -A: Set user-agent header to mimic a real browser
  • -o: Specify output filename

Additional headers for difficult sites:

curl -L \
  -A "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36" \
  -H "Accept: application/pdf,*/*" \
  -H "Accept-Language: en-US,en;q=0.9" \
  -H "Connection: keep-alive" \
  -o output.pdf "URL_HERE"

Mode B: Local File Processing & Extraction

If you already have the PDF file locally, skip Step 1 and begin here:

Step 2: Verify File Type Before Parsing

Always validate the downloaded file is actually a PDF before attempting extraction:

file output.pdf

Expected output should contain "PDF document". If not:

  • The URL may have redirected to an HTML error page
  • The file may be corrupted
  • Access may be blocked

Step 3: Primary Extraction with pdftotext

First attempt extraction using the standard pdftotext utility (part of poppler-utils):

pdftotext output.pdf output.txt

If pdftotext is not available, install it:

# Debian/Ubuntu
apt-get update && apt-get install -y poppler-utils

# macOS
brew install poppler

# RHEL/CentOS
yum install -y poppler-utils

Step 4: Fallback to PyMuPDF (fitz)

If pdftotext fails or produces poor results, use Python's PyMuPDF library:

import fitz  # PyMuPDF

doc = fitz.open("output.pdf")
text = ""
for page in doc:
    text += page.get_text()
doc.close()

with open("output.txt", "w") as f:
    f.write(text)

Install if needed:

pip install pymupdf

Step 5: Graceful Degradation to Domain Knowledge

If the PDF cannot be accessed or extracted after all attempts:

  1. Document the failure mode (network issue, corrupted file, access denied, etc.)
  2. Extract any partial content that was successfully retrieved
  3. Supplement missing content from established domain knowledge
  4. Clearly mark which portions are from source vs. generated from knowledge
  5. Provide citations for any claimed requirements or specifications

Example degradation note:

NOTE: Source document [URL] was inaccessible due to [reason]. 
Content below combines partial extraction with established domain knowledge 
for [topic]. Verify against official sources when available.

Mode C: PDF Generation with ReportLab

After extracting or processing data, generate professional PDFs using Python's reportlab library.

Installation

pip install reportlab

Step C1: Basic Document Structure

Create a multi-page PDF with title page, sections, and proper formatting:

from reportlab.lib.pagesizes import letter
from reportlab.platypus import SimpleDocTemplate, Paragraph, Spacer, PageBreak
from reportlab.lib.styles import getSampleStyleSheet, ParagraphStyle
from reportlab.lib.units import inch
from reportlab.lib.enums import TA_CENTER, TA_LEFT

def create_structured_pdf(output_path, title, sections):
    """
    Create a structured PDF with title page and sections.
    
Questions fréquentes

Que se passe-t-il si le téléchargement est bloqué ?

Le guide utilise une requête de type navigateur et propose des solutions de repli lorsque le téléchargement ne renvoie pas un vrai PDF.

Comment le texte est-il extrait ?

Le guide essaie plusieurs méthodes dans l'ordre, en commençant par des lectures simples et en passant à des outils shell ou Python.

Quelle bibliothèque crée le nouveau PDF ?

Le guide utilise reportlab pour produire le nouveau document structuré.

Détails

Description originale de l’auteur

Complete PDF lifecycle: download, extract, and generate structured documents with reportlab

repo: HKUDS/AgentPilot

Popularité

Étoiles GitHub
7.8k
Position au classement
#12915
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