Create link in pdf with pdfmake server side using node

Please, I need your help.

How can I generate link in pdf with pdfmake using node / express.

I found this solution, but they don't work :(:

"you need to extend layoutBuilder.js - your best bet is to extend the processLeaf method to handle dd like this:

var dd = {content: [{text: "Google", link: " http://google.com/ '}]};

To actually write a pdf link, you also need to extend renderLine in your printer.js file. Unfortunately we are not using pdfkit to write text, but you should be able to use the referenced function mentioned.

I am using this code to generate pdf:

var PdfPrinter = require('pdfmake/src/printer');
var printer = new PdfPrinter(fonts);

var docDefinition = {
    content: [
        'First paragraph',
        'Another paragraph, this time a little bit longer to make sure, this line will be divided into at least two lines'
    ]
};

var pdfDoc = printer.createPdfKitDocument(docDefinition);
pdfDoc.pipe(fs.createWriteStream('pdf/basics.pdf')).on('finish', function () {
    res.send(true);
});

      

thinks about your help

0


source to share





All Articles