简体   繁体   中英

How can i generate a .ejs file to pdf in NODEJS with angularjs?

I am creating a project in nodejs with AngularJS and a MySQL database. I want is to display information from the MYSQL table in a PDF, similar to a report.

Can I render an .ejs with angular to pdf and the client only see the pdf with the information? Is there any way to do this?

You could use https://www.npmjs.com/package/electron-pdf

This library generates a PDF file from an URL, you can also use it from your express application:

var ElectronPDF = require('electron-pdf')
var express = require('express')
var bodyParser = require('body-parser')
var app = express()
app.use(bodyParser.json())

var exporter = new ElectronPDF()
exporter.on('charged', () => {
    //Only start the express server once the exporter is ready 
    app.listen(port, hostname, function() {
        console.log(`Export Server running at http://${hostname}:${port}`);
    })
})
exporter.start()

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM