Pdf service can be used for pdf generating (reports, receipts and etc.) from the html sources.
Here are a few examples to get you started:
- π Generate PDF(screenshots) from the html as a string / file.
- π¦ Build your assets without headache.
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
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.
Explore the API documentation(client side and server side) and examples to learn more.
This project adheres to Semantic Versioning. Every release is documented on the Github Releases page.
Ship is released under the MIT License.
Please read CONTRIBUTING.md for details on our code of conduct, and the process for submitting pull requests to us.
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!