Why am I getting this error: Report is not a constructor. I have the package installed. I am trying to render a PDF with node and serve it to my client via http.
const express = require('express');
const db = require('../config/db');
const router = new express.Router();
const PDFDocument = require('pdfkit')
const Report = require('fluentreports')
var fs = require("fs")
router.get('/getpdf', (req, res) => {
res.type('application/pdf');
// Our Simple Data in Object format:
var data = [{name: 'Elijah', age: 18}, {name: 'Abraham', age: 22}, {name: 'Gavin', age: 28}];
// Create a Report
var rpt = new Report("Report.pdf")
.pageHeader( ["Employee Ages"] ) // Add a simple (optional) page Header...
.data( data ) // Add some Data (This is required)
.detail( [['name', 200],['age', 50]]) // Layout the report in a Grid of 200px & 50px
.render(); // Render the Report (required if you want output...)
});
module.exports = router;
via Tzvetlin Velev
No comments:
Post a Comment