Giter Club home page Giter Club logo

pdf-service's Introduction

πŸ“œ PDF Service All Contributors license PRs Welcome

Stack

Pdf service can be used for pdf generating (reports, receipts and etc.) from the html sources.

Features

Here are a few examples to get you started:

  • πŸš€ Generate PDF(screenshots) from the html as a string / file.
  • πŸ“¦ Build your assets without headache.

Installation

You should start pdf server first. It is easy to mange if you have docker:

docker pull paralect/pdf-service
docker run -d -p 3000:3000 paralect/pdf-service

After that install client library:

npm i @paralect/pdf-service-client

Quick example

In your js file write these lines:

const PdfService = require('@paralect/pdf-service-client'); // require client pdf service library
const fs = require('fs'); // fs to write file

// pdf service init
const pdfService = new PdfService({
  serverUrl: 'http://localhost:3000',
  mode: 'development',
});

// generate pdf by html string
pdfService.generatePdfByContent('<body><h1>Hello, {{name}}!</h1></body>', {
  pdfOptions: {
    format: 'Letter',
  },
  templateSystem: {
    params: {
      name: 'Your name',
    },
  },
}).then((pdfStream) => {
  const writeStream = fs.createWriteStream('./hello.pdf');

  pdfStream.pipe(writeStream);

  writeStream.on('finish', () => {
    console.log('Hello pdf was created!');
  });
});

Execution of this code should generate pdf file with 'Hello, Your name' string.

Full API Reference

Explore the API documentation(client side and server side) and examples to learn more.

Change Log

This project adheres to Semantic Versioning. Every release is documented on the Github Releases page.

License

Ship is released under the MIT License.

Contributing

Please read CONTRIBUTING.md for details on our code of conduct, and the process for submitting pull requests to us.

Contributors

Thanks goes to these wonderful people (emoji key):


KuhArt

πŸ’» πŸ“– πŸ›

Uladzimir Mitskevich

πŸ€” πŸ›

NesterenkoNikita

πŸ€” πŸ›

Andrew Orsich

πŸ€” πŸ› 🎨

Evgeny Zhivitsa

πŸ’» 🎨

ЖСня Π€ΠΈΠ»ΠΈΠΏΠΏΠΎΠ²ΠΈΡ‡

πŸ›

This project follows the all-contributors specification. Contributions of any kind welcome!

pdf-service's People

Contributors

kuhart avatar onedazy avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

pdf-service's Issues

Implement Drone CI based continuous integration process

CI server is available here and the Drone is enabled for the current repository.

V1 of the CI process:

  1. Run tests on every pull request, so we know things are okay if something changed.
  2. Publish updated Docker Image with the latest (or we could keep latest stable, and publish as 1-beta or something) tag to DockerHub after every commit.

V2 of CI process could include:

  1. Publication of the client to the NPM after release being created (drone has tag push events, we could trigger publication based on this).
  2. Publish server as Docker Image to the DockerHub.

Refactoring

Since generateImage was appeared we need an additional refactoring of our codebase. We need to update client class name and some methods because their names are still related to pdf domain.

Page error logging and requests validation

  1. Please add the following code so we can see if there are any errors when page is rendered
page.on('console', (...args) => logger.info('PAGE LOG:', ...args));

page.on('error', (err) => {
  logger.error(`Error event emitted: ${err}`);
  logger.error(err.stack);
  closeBrowser(browser);
});
  1. It would be great to add options validation, it can be just Joi schema like in ship api. pdf and screenshot methods of puppeteer have different options and by validating options we can prevent service from passing incorrect params to browser

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.