Pdfmake: How to customize generated pdf's file name

Created on 17 Jun 2016  路  6Comments  路  Source: bpampuch/pdfmake

I am generating pdf with following code, and send it to browser, when i click pdfviewer download button, filename shows like "c89d9d51-9bfa-4955-84d1-ac6e330e5875.pdf", how can i change it?
screenshot from 2016-06-17 17 13 08

createPdf(function(req,res){

var pdfDoc = printer.createPdfKitDocument(docDefinition);

//pdfDoc.pipe(fs.createWriteStream('./output.pdf'));
var chunks = [];
var result;

pdfDoc.on('data', function(chunk) {
chunks.push(chunk);
});
pdfDoc.on('end', function() {
result = Buffer.concat(chunks);
callback(result);

});

pdfDoc.end();
});

Most helpful comment

From docs (http://pdfmake.org/#/gettingstarted) to specify a custom name of PDF file you want to download, you may to achieve this:

// download the PDF (temporarily Chrome-only)
pdfMake.createPdf(docDefinition).download('optionalName.pdf');

All 6 comments

From docs (http://pdfmake.org/#/gettingstarted) to specify a custom name of PDF file you want to download, you may to achieve this:

// download the PDF (temporarily Chrome-only)
pdfMake.createPdf(docDefinition).download('optionalName.pdf');

Aswered.

How about open()?

and open()?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

kumarandena picture kumarandena  路  3Comments

davidyeiser picture davidyeiser  路  3Comments

dmatesic picture dmatesic  路  3Comments

einfallstoll picture einfallstoll  路  3Comments

SummerSonnet picture SummerSonnet  路  3Comments