@yaakadev/pdf-generator
v1.0.2
Published
NODE JS module generating PDFs using Ruby scripts.
Downloads
7
Readme
pdf-generator
NODE JS module generating PDFs using Ruby scripts.
Use PDF Generator Module
Create PDF
You can generate a PDF using createPDF
method.
It takes 3 arguments :
- the name of Ruby script you want to use
- the name of the final document
- the object using by the Ruby script
var pdf = require('../pdfgenerator')
var obj = {
"example":"test"
}
pdf.createPDF(
"./examples/simple_pdf",
"mypdf",
obj
)
If there is no error the promise will resolve with the name of the PDF. In case of error it will reject with Ruby errors
pdf.createPDF(
"./examples/simple_pdf",
"mypdf",
obj
).then(res => {console.log(res)}
).catch(err => {console.log(err)}
)
Ruby Scripts
This NODE JS module permit the execution of Ruby script generating PDFs.
Creation and rights
First, you have to write your Ruby script, which will generate a PDF.
Then, don't forget to give it correct rights for execution : chmod +x ./yourscript.rb
Don't forget that the name of document will be passed as first argument of your script.
Examples
Please see in examples
folder, you'll find a ruby script and little NodeJS programm.
You can launch this example executing this command in README.md folder : node examples/example.js