pdf

Comprehensive PDF manipulation toolkit for extracting text and tables, creating new PDFs, merging/splitting documents, and handling forms. When Claude needs to fill in a PDF form or programmatically process, generate, or analyze PDF documents at scale.

Install

Hot:3254

Download and extract to your skills directory

Copy command and send to AI Agent for auto-install:

Download and install this skill https://openskills.cc/api/download?slug=composiohq-document-skills-pdf&locale=en&source=copy

PDF Processing Skills – Python Document Automation Toolkit

Skill Overview


PDF Processing Skills is a comprehensive set of Python document manipulation tools for extracting text and tabular data from PDFs, creating new documents, merging and splitting files, and handling form filling tasks, helping users automate document processing.

Applicable Scenarios

  • Data Extraction and Analysis – Extract structured data from invoices, reports, and scanned documents, with support for table recognition and OCR text recognition. Suitable for finance, data analysis, and other scenarios that require the digitization of large volumes of paper documents.
  • Automated Document Generation – Use ReportLab to create formatted PDF reports, contracts, certificates, and other documents, or generate personalized documents in batches through templates. Suitable for corporate reports, automated notification generation, and similar scenarios.
  • Batch Document Processing – Merge multiple scanned files, split large documents, and add watermarks or password protection in batches. Suitable for records management, file organization, document security, and routine office tasks.
  • Core Functions

  • Text and Table Extraction – Use pdfplumber to accurately extract text content and tabular data from PDFs while preserving the original layout. It supports the recognition of complex table structures and allows extracted data to be converted directly into Excel format for further analysis.
  • PDF Operations and Conversion – Use pypdf to perform basic operations such as merging, splitting, rotating, and watermarking documents. It also supports batch processing through command-line tools such as qpdf and pdftk, combined with OCR technology for handling scanned documents.
  • PDF Creation and Form Processing – Use the ReportLab library to create PDF documents from scratch, with support for multi-page layouts, mixed text and image content, and custom styles. It also provides form-filling functionality, allowing PDF form fields to be populated automatically and saved.
  • Frequently Asked Questions

    How can I extract table data from a PDF into Excel?


    The pdfplumber library can identify table structures in PDFs and extract their data. Example code:

    import pdfplumber
    import pandas as pd
    
    with pdfplumber.open("document.pdf") as pdf:
        all_tables = []
        for page in pdf.pages:
            tables = page.extract_tables()
            for table in tables:
                if table:
                    df = pd.DataFrame(table[1:], columns=table[0])
                    all_tables.append(df)
        
        if all_tables:
            combined_df = pd.concat(all_tables, ignore_index=True)
            combined_df.to_excel("extracted_tables.xlsx", index=False)

    Which Python library is best for processing PDFs?


    Different libraries are suitable for different tasks:

  • pypdf – Best for basic operations such as merging, splitting, rotating, and encrypting

  • pdfplumber – Best for text and table extraction, with high recognition accuracy

  • ReportLab – Best for creating PDFs from scratch, with support for complex layouts

  • pytesseract + pdf2image – Suitable for OCR recognition of scanned documents

  • pdf-lib – Suitable for JavaScript environments or scenarios requiring form filling
  • Most tasks can be completed by combining these libraries. The specific choice depends on your requirements and development environment.

    How can I merge multiple PDF files in batches?


    You can easily merge multiple PDFs using pypdf:

    from pypdf import PdfWriter, PdfReader
    
    writer = PdfWriter()
    for pdf_file in ["doc1.pdf", "doc2.pdf", "doc3.pdf"]:
        reader = PdfReader(pdf_file)
        for page in reader.pages:
            writer.add_page(page)
    
    with open("merged.pdf", "wb") as output:
        writer.write(output)

    For batch processing via the command line, you can use qpdf:

    qpdf --empty --pages file1.pdf file2.pdf -- merged.pdf

    How can I extract text from a scanned PDF?


    A scanned PDF consists of images, so it must first be converted into images and then processed using OCR:

    import pytesseract
    from pdf2image import convert_from_path
    
    images = convert_from_path('scanned.pdf')
    text = ""
    for i, image in enumerate(images):
        text += f"Page {i+1}:\n"
        text += pytesseract.image_to_string(image)
        text += "\n\n"

    This requires the Tesseract OCR engine and the pdf2image library. Recognition accuracy depends on the quality of the document and the clarity of the text.

    Can PDF processing recognize handwriting?


    Standard OCR tools such as Tesseract perform well when recognizing printed text, but have limited ability to recognize individual handwriting. If handwritten content must be recognized, it is recommended to:

  • Use more advanced OCR services, such as Google Cloud Vision API or Azure OCR

  • Consider manual proofreading or manually digitizing the handwritten content

  • For scenarios involving handwritten signatures on forms, use specialized signature recognition tools
  • Most document processing scenarios, such as invoices, reports, and contracts, involve printed text, for which standard OCR is generally sufficient.