Giter VIP home page Giter VIP logo

pypdfht's Introduction

pypdfht

Overview

pypdfht is a simple python app to highlight text within PDF files. It provides a simple API for identifying and highlighting specific strings of text on any given page of a PDF.

Features

  • Text Highlighting: Utilize the highlight_entire_text_on_page function to programmatically highlight text on a PDF page.

API Example

    data = {
        'page_number': 3,
        'text': 'void function(int a, int b, int c) { char buffer1[5]; char buffer2[10]; }'
    }
    
    # Files to be uploaded (if any)
    files = {
        'file': open('example.pdf', 'rb')  # Replace 'example.pdf' with the actual file path
    }    
    # Make a POST request to the Flask route
    response = requests.post('http://localhost:5000/highlight', data=data, files=files)
    # Decode the JSON response
    response_data = response.json()
    
    if 'error' in response_data:
        print(response_data)
        return

    with open('highlighted_image.png', 'wb') as f:
        # Decode the base64 string to bytes directly
        decoded_image_data = base64.b64decode(response_data['image_data_base64'])
        f.write(decoded_image_data)

highlightedimage

Usage

To use the highlighting feature, ensure you have a running instance of the server that includes the highlight route as defined in app.py. Then, use the curl command above to send a request to the server.

Installation

Clone the repository and install the required Python packages:

git clone https://github.com/nagendra-y/pypdfht.git
cd pypdfht
pip install -r requirements.txt

Running the Server

To start the server, run:

python app.py

This will start a Flask server that listens for requests to highlight text in PDF files.

pypdfht's People

Contributors

nagendra-y avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.