मुख्य सामग्री पर जाएँ
Skillpedia
PDF, Word और स्लाइड7.8k · #12915

pdf-extract-create-workflow

यह क्या करती है

यह स्किल PDF का पूरा चक्र कवर करती है: PDF प्राप्त करना, उसका टेक्स्ट पढ़ना और reportlab से नया फ़ॉर्मेट किया हुआ PDF बनाना। यह उन लोगों के लिए है जो वेबसाइटों या अपनी फ़ाइलों से PDF लेते हैं और नतीजे में नया दस्तावेज़ चाहते हैं।

कब इस्तेमाल करें

  • ✓जब PDF वेबसाइट पर हो और पहले उसे डाउनलोड करना ज़रूरी हो।
  • ✓जब मुझे PDF का टेक्स्ट चाहिए और फिर उसी सामग्री से नया PDF बनवाना है।
  • ✓जब PDF पहले से मेरे कंप्यूटर पर हो और मुझे सिर्फ़ निकासी और नया दस्तावेज़ बनाने के चरण चाहिए।

Skill का लिंक

https://github.com/HKUDS/AgentPilot/blob/main/openspace/benchmarks/gdpval/skills/pdf-download-extract-fallback-enhanced-29b2f4/SKILL.md

इसे कॉपी करके अपने AI (Claude, ChatGPT या Cursor) में पेस्ट करें और निर्देशों का पालन करने को कहें।

कैसे इस्तेमाल करें

सबसे आसान तरीका: मैसेज कॉपी करके अपने AI में पेस्ट करें। वह skill पढ़कर निर्देशों का पालन करेगा।

पेस्ट करने के लिए तैयार मैसेज

इस skill से मेरी मदद करो: https://github.com/HKUDS/AgentPilot/blob/main/openspace/benchmarks/gdpval/skills/pdf-download-extract-fallback-enhanced-29b2f4/SKILL.md इस लिंक की SKILL.md फ़ाइल पढ़ो और मेरे काम में उसके निर्देशों का पालन करो।
क्या आप चाहते हैं कि आपका AI ऐसी skills खुद ढूँढे?मुफ़्त Skillpedia MCP इंस्टॉल करें: बस एक लाइन, और हर काम से पहले यह 15,000+ skills में खोजता है।1 मिनट में इंस्टॉल करें →

AI से क्या माँगें: उदाहरण

“इस लिंक से PDF डाउनलोड कीजिए, उसका टेक्स्ट निकालिए, और फिर reportlab से मेरे लिए एक नया संरचित PDF सारांश बनाइए।”

हर हफ़्ते 5 नई skills, 1 मिनट में पढ़ें।

यह कैसे काम करती है

AI ब्राउज़र जैसे अनुरोध से फ़ाइल डाउनलोड करता है, जाँचता है कि वह सच में PDF है, सबसे अच्छे उपलब्ध टूल से टेक्स्ट निकालता है और संसाधित सामग्री से नया दस्तावेज़ बनाता है।

तकनीकी सामग्री (मूल SKILL.md)

लेखक का मूल टेक्स्ट, अंग्रेज़ी में, सीधे 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.
    
अक्सर पूछे जाने वाले सवाल

अगर डाउनलोड रोका जाए तो?

गाइड ब्राउज़र जैसा अनुरोध इस्तेमाल करती है और जब डाउनलोड असली PDF न दे, तब फ़ॉलबैक देती है।

टेक्स्ट कैसे निकाला जाता है?

गाइड क्रम से कई तरीके आज़माती है, सरल रीड से शुरू करके शेल या Python टूल तक।

नया PDF कौन सी लाइब्रेरी बनाती है?

गाइड नया संरचित दस्तावेज़ बनाने के लिए reportlab इस्तेमाल करती है।

जानकारी

लेखक का मूल विवरण

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

repo: HKUDS/AgentPilot

लोकप्रियता

GitHub स्टार
7.8k
रैंकिंग में स्थान
#12915
लाइसेंस
MIT
अपडेट की गई
1/11/2026

क्या यह skill काम की है?

0

लॉग इन करें वोट करने के लिए।

कमेंट

  • …

इस repository की और skills

मिलती-जुलती skills