Pdfmake: How to display pdf object in canvas container?

Created on 14 Dec 2015  路  2Comments  路  Source: bpampuch/pdfmake

Hi All,

I have to put pdfmake object:

[ var doc = pdfMake.createPdf(docDefinition) ]

into a canvas object. Basically, I want to display pdf preview before I will print it.
I have tried to use drawImage method from Canvas API but I get message that input stream is invalid.

Is Pdfmake support such operation or do you know suitable alternative?

Thanks

Most helpful comment

Try this

in html
< iframe id='pdfV' style="width:100%; height: 500px" >

in js
pdfMake.createPdf(docDefinition).getDataUrl(function (outDoc) {
document.getElementById('pdfV').src = outDoc;
});

All 2 comments

Try this

in html
< iframe id='pdfV' style="width:100%; height: 500px" >

in js
pdfMake.createPdf(docDefinition).getDataUrl(function (outDoc) {
document.getElementById('pdfV').src = outDoc;
});

Hi Daupawar

Thank you. It is working brilliantly.

Was this page helpful?
0 / 5 - 0 ratings