how to return pdf from dynamic xml file content



  • how to return pdf from dynamic xml file .
    I was trying to Generate throw without template with xml source but m not able to do so kindly suggest some way

    exports.covertHtmlToPDf = [
        async function (req, res) {
            try {
                let jsreportError = '';
                let source = JSON.stringify(req.body.data);
                logger.info("---Reaching convertHtmlToPdf,  printData - " + JSON.stringify(source) + "");
    
                let reportData = {
                    template: {
                        content: source,
                        engine: 'handlebars',
                        recipe: 'chrome-pdf'
                    },
                };
    
                let res1 = await jsreport.render(reportData).catch((e) => {
                    jsreportError = e.message;
                }).then((out) => {
                    // console.log("res",JSON.stringify(res))
                    out.stream.pipe(res);
                    
                    logger.info("Html successfully converted into pdf.")
                });
    
            } catch (err) {
                res.end(err);
            }
        }
    ]
    

    with above code with post api call



  • I'm sorry but I don't get what you mean.

    Do you have random XML content and do you want to convert it into pdf?
    How that should look in the end?


Log in to reply
 

Looks like your connection to jsreport forum was lost, please wait while we try to reconnect.