Initial commit

This commit is contained in:
Mike Conrad
2024-10-23 10:42:55 -04:00
commit cc4a321837
6 changed files with 933 additions and 0 deletions

27
index.js Normal file
View File

@ -0,0 +1,27 @@
const carbone = require('carbone');
const express = require('express')
const PORT = 8000;
const OPTIONS = { convertTo: 'pdf', lang: 'en-us', currencyTarget: 'USD' };
const app = express();
app.use(express.json())
app.use(express.urlencoded({extended: true}))
app.post('/api/convert', (req, res) => {
// Generate a report using the sample template provided by carbone module
// This LibreOffice template contains "Hello {d.firstname} {d.lastname} !"
carbone.render('./node_modules/carbone/examples/simple.odt', req.body, OPTIONS, function(err, result){
if (err) {
return console.log(err);
}
res.set('Content-Type', 'application/pdf');
res.end(result);
});
});
app.listen(PORT, () => {
console.log(`PDF Converter listening on ${PORT}`);
});