Using savePDF on empty table creates corrupted PDF file

Posted by: jonathan.gross on 23 January 2019, 8:20 pm EST

    • Post Options:
    • Link

    Posted 23 January 2019, 8:20 pm EST

    I guess it’s a bug, unless there is some setting that I can use to print empty tables

    See attached exampleSpreadJSPdfExportEmptyTable.html.zip

  • Posted 24 January 2019, 5:30 am EST

    Hi,

    This is not a bug but intended design behaviour. We can specify settings like start/end row/column for the exported sheet. And if we do not specify any settings then spread automatically export the min no of row/columns possible without losing the data, since there is no data in the sheet, no of exported row/columns is calculated to be 0, hence the blank PDF.

    Please modify the export code as below and you would be able to export blank sheets as intended:

    
    var spread = new GC.Spread.Sheets.Workbook(document.getElementById("ss"));
                var pInfo = spread.getActiveSheet().printInfo();
                pInfo.columnStart(0);
                pInfo.columnEnd(5);
                pInfo.rowStart(0);
                pInfo.rowEnd(10);
                $('#savePDF').click(function() {
                    spread.savePDF(function (blob) {
                        var fileName = $('#fileName').val() || 'download';
                      
                        saveAs(blob, fileName + '.pdf');
    
                    }, function(error) {
                        console.log(error);
                    });
                });
    

    You may refer to the following doc which lists all possible setting for pdf export: http://help.grapecity.com/spread/SpreadSheets12/webframe.html#SpreadJS~GC.Spread.Sheets.Print.PrintInfo.html

    ~Sharad

Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels