Giter VIP home page Giter VIP logo

hpdf's Introduction

hpdf

standard-readme compliant

NodeJS's library for generating PDF from HTML with pool of browsers (puppeteer) in the background.

There are enough NodeJS libraries to generate PDF from HTML. Why do you need another one?

  • There is no up-to-date libraries.
  • There is no libraries with pool (but we have to use pooling when we are talking about browser in the background)

Features:

  • Configurable pool of pages (as resources) in the background
  • Fully tested
  • Written in TypeScript

How it works

Table of Contents

Install

npm install hpdf

Usage

import fs from 'fs';
import { PdfGenerator } from './src';

const start = async () => {
    const generator = new PdfGenerator({
        min: 3,
        max: 10,
    });

    const helloWorld = await generator.generatePDF('<html lang="html">Hello World!</html>');
    const github = await generator.generatePDF(new URL('https://github.com/frimuchkov/hpdf'));

    await fs.promises.writeFile('./helloWorld.pdf', helloWorld);
    await fs.promises.writeFile('./github.pdf', github);

    await generator.stop();
}

Before using puppeteer you have to install an additional libs:

FROM node:16-alpine AS base

# Installs latest Chromium (89) package.
RUN apk add --no-cache \
      chromium \
      nss \
      freetype \
      harfbuzz \
      ca-certificates \
      ttf-freefont

# Tell Puppeteer to skip installing Chrome. We'll be using the installed package.
ENV PUPPETEER_SKIP_CHROMIUM_DOWNLOAD=true \
    PUPPETEER_EXECUTABLE_PATH=/usr/bin/chromium-browser

WORKDIR /app

COPY . .

RUN npm ci
RUN npm run build
RUN npm ci --omit=dev


RUN apk add --no-cache tini
ENTRYPOINT ["/sbin/tini", "--"]

Maintainers

@frimuchkov

Contributing

PRs accepted. Everything accepted. Feel free to improve everything you wish.

Small note: If editing the README, please conform to the standard-readme specification.

License

MIT © 2022 Andrey Frimuchkov

hpdf's People

Contributors

frimuchkov avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  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.