/pdf-service

A docker based service for pdf and image generation

Primary LanguageJavaScriptMIT LicenseMIT

πŸ“œ 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!