Giter Site home page Giter Site logo

url2pdf's Introduction

URL to PDF Converter

This Python script converts images from a given URL into a PDF document. It fetches the HTML content from the URL, extracts the image elements, and generates a PDF file containing the images along with their alt text.

Prerequisites

  • Python 3.x
  • requests library
  • bs4 library (BeautifulSoup)
  • reportlab library

Installation

  1. Clone the repository:

    git clone https://github.com/your-username/image-to-pdf-converter.git
    cd image-to-pdf-converter
    
  2. Install the required libraries using pip:

    ./requirements.sh
    

Usage

Run the main.py file with the following command:

python main.py --URL [URL] --RESULT [output_file]

Replace [URL] with the URL containing the images you want to convert, and [output_file] with the desired name of the output PDF file.

For example:

python main.py --URL https://example.com/images --RESULT output.pdf

The script will download the HTML content from the given URL, extract the image elements, and generate a PDF file named output.pdf containing the images and their alt text.

Logging

The script logs the application's activities using two separate log files:

app.log: Logs informational messages such as URL provided, output file provided, URL content downloaded, list of all images fetched successfully, PDF created, and output file generated successfully.

error.log: Logs error messages such as failed to fetch the HTML content, invalid URL provided, an error occurred during the HTTP request, no image found in the URL, and temporary folder not present.

You can find the log files in the .log directory within the project folder.

License

This project is licensed under the MIT License. basic

Feel free to customize the content and formatting of the README file according to your preferences and specific requirement

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.