본문으로 건너뛰기
Skillpedia
PDF, Word, 슬라이드7.8k · #12915

pdf-extract-create-workflow

하는 일

이 스킬은 PDF의 전체 과정을 다룹니다. PDF를 얻고, 텍스트를 읽고, reportlab으로 새 서식 문서를 만듭니다. 웹사이트나 자신의 파일에서 PDF를 다루고 결과로 새 문서가 필요한 사람에게 맞습니다.

사용하는 경우

  • ✓PDF가 웹사이트에 있어 먼저 내려받아야 할 때.
  • ✓PDF에서 텍스트를 얻고 그 내용으로 새 PDF를 만들고 싶을 때.
  • ✓PDF가 이미 컴퓨터에 있고 추출과 새 문서 단계만 필요한 경우.

스킬 링크

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

복사해서 AI(Claude, ChatGPT, Cursor)에 붙여넣고 지침을 따르도록 요청하세요.

사용 방법

가장 쉬운 방법입니다. 메시지를 복사해 AI에 붙여넣으세요. AI가 스킬을 읽고 지침을 따릅니다.

바로 붙여넣을 수 있는 메시지

Use this skill to help me: https://github.com/HKUDS/AgentPilot/blob/main/openspace/benchmarks/gdpval/skills/pdf-download-extract-fallback-enhanced-29b2f4/SKILL.md Read the SKILL.md file at that link and follow its instructions for my task.
AI가 이런 스킬을 알아서 찾아 쓰길 원하시나요?무료 Skillpedia MCP를 설치하세요. 한 줄이면 작업마다 스킬 15,000+개 중에서 검색합니다.1분 만에 설치 →

AI에게 요청하는 예시

“이 링크에서 PDF를 내려받아 텍스트를 꺼내고, reportlab으로 구조화된 새 PDF 요약을 만들어 주세요.”

매주 새 스킬 5개. 읽는 데 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
업데이트
2026. 11. 1.

이 스킬이 유용한가요?

0

로그인 투표하려면 로그인하세요.

댓글

  • …

이 저장소의 다른 스킬

비슷한 스킬