pdf report with sails.js

1,353 views
Skip to first unread message

Leonan Luppi

unread,
Apr 29, 2014, 9:24:07 AM4/29/14
to sai...@googlegroups.com
Hello,

Someone has a tutorial to generate PDF reports with sails.js?

Thanks!

Alberto Souza

unread,
Apr 29, 2014, 2:35:31 PM4/29/14
to Leonan Luppi, sai...@googlegroups.com
I have an application running with "wkhtmltopdf" for create certifications from html templates in one service and use it on controller ... i think this can help you

Links:

it is not the best way but works ...

Alberto Souza

John Tomaselli

unread,
May 1, 2014, 2:12:44 PM5/1/14
to sai...@googlegroups.com, Leonan Luppi
I've used PDFKit,A PDF generation library for Node.js.
Check out some of the 
[documentation and examples](http://devongovett.github.com/pdfkit/docs/getting_started.html) to see for yourself!

From Controller 
var PDFDocument = require('pdfkit');
TWOController= {
  
    createPDF: function (req,twoid) {
        console.log('-----success--------updateWrapped---cambriai----calibri-------------pdfCreate-----params------------', req.params.all());//,poid,req.body)
        var objid = req.body.id;
        console.log('-----success--------updateWrapped---cambriai----calibri-------------pdfCreate-----params------------',twoid)
        var par = req.param;
        doc = new PDFDocument;
        doc.info['Title'] = 'PTTest';
        doc.info['Author'] = 'John Tomaselli';
        doc.registerFont('Palatino', './api/fonts/PalatinoBold.ttf');
        doc.registerFont('cambria', './api/fonts/Cambria.ttc');
        var startcol = 45;
...
       // get signature image
        doc.image('./api/uploads/dk.jpg', startcol-12, linePos-60)
        //line cap settings
        doc.lineWidth(2);
        doc.lineCap('butt')
            .moveTo(startcol, linePos)
            .lineTo(startcol + 155, linePos)
            .stroke()
            .moveTo(startcol2, linePos)
            .lineTo(startcol2 + 75, linePos)
            .stroke();
        linePos += 2;// 5;
        doc.font('Palatino', 12).fillColor("blue").text(' Authorized Signature ', startcol, linePos).text('Date', startcol2, linePos);
        doc.write('./api/uploads/two/two' + twoid + '.pdf');

    },

Leonan Luppi

unread,
May 2, 2014, 7:01:36 AM5/2/14
to sai...@googlegroups.com, Leonan Luppi
I had been seen this module... and I got it but if I want to display this PDF in the browser, do you have one solution for?
Reply all
Reply to author
Forward
0 new messages