Coder Social home page Coder Social logo

imgs-to-pdf's Introduction

Image Downloader & PDF Converter

This Node.js script allows for downloading images from a list of URLs and converting them into PDF format. It supports different modes for downloading images, creating PDFs, and cleaning up after conversion.

Features

  • Downloads images from provided URLs.
  • Converts downloaded images into PDF format.
  • Supports different modes: download only, download and convert to PDF, download and convert to PDF with image cleanup.
  • Flexible image selection using CSS selectors.

Requirements

  • Node.js
  • Puppeteer
  • Axios
  • ImageMagick (for PDF conversion)

Installation

Clone or download the repository.

Install the required Node.js modules:

npm install

Ensure ImageMagick is installed on your system for PDF conversion.

Usage

Create a file named urls.txt in the script's directory. Add the URLs, each on a new line.

Run the script with one of the following commands, depending on the desired mode:

Download Images Only:

If you want all images on the page, use the following command:

node index.js [BaseName]

If you want to target specific images, use the following command:

node index.js [BaseName] images [CssSelector]

Download Images and Convert to PDF:

node index.js [BasePdfName] pdf [CssSelector]

Download Images, Convert to PDF, then Remove Images:

node index.js [BasePdfName] pdfclean [CssSelector]

Replace [BasePdfName] with the desired base name for the output PDFs, and [CssSelector] with the CSS selector to target images on the page (default is 'img').

PDFs and/or images will be stored in folders named after the base PDF name, with sequence numbers appended.

Notes

The script processes each URL in urls.txt and generates a PDF for each batch of images fetched.

Ensure the website is accessible and the CSS selector correctly targets the image elements.

The script may require adjustments for specific websites or for handling different web page structures.

Disclaimer

This script is intended for personal use and educational purposes. Ensure you have the right to download and convert content from the provided URLs. Respect copyright laws and the terms of service of the websites you are accessing.

imgs-to-pdf's People

Contributors

djenntt avatar

Stargazers

 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.