bpampuch / pdfmake

Client/server side PDF printing in pure JavaScript
http://pdfmake.org
Other
11.7k stars 2.04k forks source link

Not working with IE #219

Closed munikumar604 closed 9 years ago

munikumar604 commented 9 years ago

Hi Team, I used pdfmake in IE it is not working properly.

jthoenes commented 9 years ago

Duplicate of #16

munikumar604 commented 9 years ago

Hi jthoenes, How to create pdf using pdf make In IE. Please help me.

Thanks , Muni

jthoenes commented 9 years ago

Hi,

unfortunately, pdfmake does not support IE as of now.

Best regards Johannes

Wabbala commented 9 years ago

@munikumar604 and @jthoenes, check my work around in #16

munikumar604 commented 9 years ago

Hi wabbala, Your way also not working,

<!DOCTYPE html>

```

above is my page. pdf is not created

Wabbala commented 9 years ago

Does the example I linked to work with you?

On 4 March 2015 at 14:20, munikumar604 notifications@github.com wrote:

Hi wabbala, Your way also not working,

<!DOCTYPE html>

— Reply to this email directly or view it on GitHub https://github.com/bpampuch/pdfmake/issues/219#issuecomment-77155894.

mathewbeno commented 9 years ago

Do we get a fix for it?

bpampuch commented 9 years ago

As I've written in #230 - "Data URIs in IE can only be used for images. This is an IE limitation. Unfortunately I have no concept for a workaround"

Dev63 commented 9 years ago

@bpampuch How about putting the data in LocalStorage, and asking the caller to host a blank template page on their site (which could be fixed name or a setting option) which will read and display that data?

@jthoenes You closed this issue and marked it a duplicate of an IE9 issue ... but this is about IE11. Did something change recently, or has pdfmake never supported IE (I thought it did!).

bpampuch commented 9 years ago

@Dev63 if we set the content type to application/pdf browser won't execute the code so we can't access localstorage

bpampuch commented 9 years ago

The only workaround I know is an echo service (you send the file to the server and it sends it back) for IE, but this sucks IMO

PaulL1 commented 9 years ago

@bpampuch: We're using this library in the angular-ui-grid, thanks for the excellent code.

We have a function that downloads csv files in IE, it has a complex set of detection logic and specific functionality for different browsers, but it does allow download of arbitrary browser created content. It'd be nice if pdfMake also offered a similar functionality, as for pdfMake we're currently just calling the .download() method.

The relevant code file is https://github.com/angular-ui/ng-grid/blob/master/src/features/exporter/js/exporter.js, the relevant method is downloadFile at or about line 769. To see it working you can view the tutorial for the export feature: http://ui-grid.info/docs/#/tutorial/206_exporting_data. The basic steps are to click the grid menu (icon top right of the grid), and select "export all data as csv".

If it isn't possible to implement the download function, then perhaps you could answer a different question - can I get the rendered pdf from pdfMake and then execute the download myself?

raghav135 commented 9 years ago

Getting this error in IE 10 with pdfmake

http://ui-grid.info/docs/#/tutorial/206_exporting_data

TypeError: Object doesn't support property or method '__defineGetter__'
   at FontWrapper (http://ui-grid.info/docs/grunt-scripts/pdfmake.js:14169:4)
   at provideFont (http://ui-grid.info/docs/grunt-scripts/pdfmake.js:2269:4)
   at Anonymous function (http://ui-grid.info/docs/grunt-scripts/pdfmake.js:16130:4)
   at measure (http://ui-grid.info/docs/grunt-scripts/pdfmake.js:16118:3)
   at buildInlines (http://ui-grid.info/docs/grunt-scripts/pdfmake.js:15941:3)
   at measureLeaf (http://ui-grid.info/docs/grunt-scripts/pdfmake.js:14557:3)
   at Anonymous function (http://ui-grid.info/docs/grunt-scripts/pdfmake.js:14437:5)
   at auto (http://ui-grid.info/docs/grunt-scripts/pdfmake.js:16306:3)
   at measureNode (http://ui-grid.info/docs/grunt-scripts/pdfmake.js:14422:3)
   at Anonymous function (http://ui-grid.info/docs/grunt-scripts/pdfmake.js:14709:5) 
paulkoegel commented 8 years ago

a browser support table in the README would be nice.

jgdovin commented 8 years ago

One possibility I am currently looking into as a work around is integrating Mozilla's PDF.js into our app and passing it a dataUri from PDFMake. This should allow it to work in IE. Link to Mozilla PDF.js here: https://mozilla.github.io/pdf.js/

pburrows commented 8 years ago

Just saw that jsPDF is using downloadify for IE compatibility https://parall.ax/products/jspdf

sirhcybe commented 8 years ago

I ran into this issue and decided to go with using feature detection to find if data URIs are supported for opening PDFs and using the .download() function if they were not. I had a hard time finding a good feature detection script for this so I thought I'd post it here for anyone else who's looking for one. The best one I could find was proposed by KevinMartin in a Modernizr issue.

nigel-dewar commented 8 years ago

Why would you make a library that doesn't work in IE?

sebass commented 8 years ago

as stated before: a browser support table in the README would be nice...

samaelsimoes commented 7 years ago

Hello good morning, I found this solution, it´s working for me. ExpenseService.query(function(ex) { // ex IS MY RETURN SERVER

        var dataexp = [];
        var body = [];

        var columns = {numero: 'número', usuario: 'usuario', descricao: 'descrição', valor:'Valor R$', 
                       valorAdiantamento:'Adiantamento', data:'Data', situacao:'Situação', 
                       centrocusto:'Centro de Custo', objetivo:'Objetivo', tipodespesa:'Tipo de Despesa'
                      }

        for (var i = 0; i < ex.length; i++) { // Created 1º format reportexpense

            var object = {};        

            if(i === 0){
                dataexp.push(columns);
            }

            object.code = ex[i].code.toString();
            object.userOid = ex[i].userOid;
            object.description = ex[i].description;
            object.value = ex[i].value.toString();
            object.paidValue = ex[i].paidValue.toString();
            object.date = ex[i].date;

             if( ex[i].situation == 0 ) {

                 object.situation = "Concluído";
            }else if( ex[i].situation == 1 ) {

                 object.situation = "Pago";
            }else if( ex[i].situation == 2 ) {

               object.situation = "Concluído";
            }else if( ex[i].situation == 3 ) {

                object.situation = "Aprovado";
            }else if( ex[i].situation == 4 ) {

                object.situation = "Pago";
            }

            object.costcenter = ex[i].costecenterOid;
            object.reason = ex[i].reason;
            object.type = ex[i].typeOid;

            dataexp.push(object);   
        }

        for (var key in dataexp) { // convert 2º format report expense array['value','value'...]

            var dexp = dataexp[key];
            var reportexp = [];

            if(key === "0"){// Create header report expense
                reportexp.push( dexp.numero );
                reportexp.push( dexp.usuario );
                reportexp.push( dexp.descricao );
                reportexp.push( dexp.valor );
                reportexp.push( dexp.valorAdiantamento );
                reportexp.push( dexp.data );
                reportexp.push( dexp.situacao );
                reportexp.push( dexp.centrocusto );
                reportexp.push( dexp.objetivo );
                reportexp.push( dexp.tipodespesa );
                body.push( reportexp );
            }else if( key != "0"){              
                reportexp.push( dexp.code );
                reportexp.push( dexp.userOid );
                reportexp.push( dexp.description );
                reportexp.push( dexp.value  );
                reportexp.push( dexp.paidValue );
                reportexp.push( dexp.date);
                reportexp.push( dexp.situation );
                reportexp.push( dexp.costcenter );
                reportexp.push( dexp.reason );
                reportexp.push( dexp.type );                    
                body.push( reportexp );
            }
        }   

        var dexps = {

            pageSize : 'A3',                       
            content: [
                {text: 'Wizfee - controle de despesa ', style: 'header'},                   
                {       
                width: 500,
                    table: {                            
                        style: 'tableExample',
                        headerRows: 1,
                        widths: [50, 55, 55, 55, 80, 70, 55, 85, 75, 80], 
                        body: body                  
                    },
                    //layout: 'noBorders'
                },
                //{ width: '*', text: 'Wizfee - controle de despesa ' },
            ],
            styles: {
                header: {
                    fontSize: 18,
                    bold: true,
                    margin: [0, 0, 0, 10]
                },
                subheader: {
                    fontSize: 16,
                    bold: true,
                    margin: [0, 10, 0, 5]
                },
                tableExample: {
                    margin: [0, 5, 0, 15]
                },
                tableHeader: {
                    bold: true,
                    fontSize: 13,
                    color: 'black'
                }
            },
            defaultStyle: {
                alignment: 'justify'
            }
        };

        pdfMake.createPdf(dexps).open();
        pdfMake.createPdf(dexps).download('despesas.pdf');
    }, function( error ) {           
        toastr.error( error );
    });
mikeplate commented 7 years ago

There is apparently an IE specific API for downloading blobs.

https://msdn.microsoft.com/en-us/library/hh779016%28v=vs.85%29.aspx?f=255&MSPPError=-2147217396

I just changed from:

pdfMake.createPdf(doc).download("Report.pdf");

to

if (window.navigator.msSaveBlob) {
    pdfMake.createPdf(doc).getBlob(function (result) {
        window.navigator.msSaveBlob(result, "Rapport.pdf");
    });
}
else {
    pdfMake.createPdf(doc).download("Report.pdf");
}
tcsaddul commented 5 years ago

Would instruct clients to use Firefox or Chrome

liborm85 commented 5 years ago

download action works also in IE.