Coder Social home page Coder Social logo

asieduernest12 / pdf2html Goto Github PK

View Code? Open in Web Editor NEW

This project forked from shebinleo/pdf2html

0.0 1.0 0.0 399 KB

pdf2html is a module which helps to convert PDF file to HTML pages using Apache Tika. This module also helps to generate thumbnail image for PDF file using Apache PDFBox.

Home Page: https://www.npmjs.com/package/pdf2html

License: Apache License 2.0

JavaScript 100.00%

pdf2html's Introduction

pdf2html

NPM version npm module downloads Build Status view on npm

pdf2html helps to convert PDF file to HTML or Text using Apache Tika. This module also helps to generate thumbnail image for PDF file using Apache PDFBox.

Installation

via yarn:

yarn add pdf2html

via npm:

npm install --save pdf2html

Java runtime environment (JRE) is required to run this module.

Usage

const pdf2html = require('pdf2html')

pdf2html.html('sample.pdf', (err, html) => {
    if (err) {
        console.error('Conversion error: ' + err)
    } else {
        console.log(html)
    }
})

Convert to text

pdf2html.text('sample.pdf', (err, text) => {
    if (err) {
        console.error('Conversion error: ' + err)
    } else {
        console.log(text)
    }
})

Convert as pages

pdf2html.pages('sample.pdf', (err, htmlPages) => {
    if (err) {
        console.error('Conversion error: ' + err)
    } else {
        console.log(htmlPages)
    }
})
const options = { text: true }
pdf2html.pages('sample.pdf', options, (err, textPages) => {
    if (err) {
        console.error('Conversion error: ' + err)
    } else {
        console.log(textPages)
    }
})

Extra metadata

pdf2html.meta('sample.pdf', (err, meta) => {
    if (err) {
        console.error('Conversion error: ' + err)
    } else {
        console.log(meta)
    }
})

Generate thumbnail

pdf2html.thumbnail('sample.pdf', (err, thumbnailPath) => {
    if (err) {
        console.error('Conversion error: ' + err)
    } else {
        console.log(thumbnailPath)
    }
})
const options = { page: 1, imageType: 'png', width: 160, height: 226 }
pdf2html.thumbnail('sample.pdf', options, (err, thumbnailPath) => {
    if (err) {
        console.error('Conversion error: ' + err)
    } else {
        console.log(thumbnailPath)
    }
})

Manually download dependencies files

Sometimes downloading the dependencies might be too slow or unable to download in a HTTP proxy environment. Follow the step below to skip the dependency downloads.

cd node_modules/pdf2html/vendor
# These URLs come from https://github.com/shebinleo/pdf2html/blob/master/postinstall.js#L6-L7
wget https://archive.apache.org/dist/pdfbox/2.0.26/pdfbox-app-2.0.26.jar
wget https://archive.apache.org/dist/tika/2.4.0/tika-app-2.4.0.jar

pdf2html's People

Contributors

aashari avatar abowcut avatar bluelovers avatar comvidnet avatar dependabot[bot] avatar jonmadison-amzn avatar shebinleo avatar svtd 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.