Does toPDF or toPNG support UnitList?

CDN libs are included in project as outlined in documentation. When we call toPDF passing the UnitList Object ID we get nothing. No error.

webix.toPDF( $$( unitListId ) );

Even when we use a List object we get nothing.
We run the code local as well as on our staging servers to no avail.

toPDF() returns the following however.

e
er: null
fn: null
next: Array (0)
No Properties.
Array Prototype
promise: e
er: null
fn: null
next: Array (0)
No Properties.
Array Prototype
promise: e {promise: e, state: “pending”, val: null, fn: null, er: null, …}
state: “pending”
val: null
e Prototype
state: “pending”
val: null
e Prototype

By default all works correctly:

http://webix.com/snippet/dc6041af

Please double-check the way to the CDN

So I’m suppose to guess. You have no reference to $unitlist1 so how does this work.

The passing the proper ID won’t work $$( poprerID ). With dynamic code guessing isn’t an option.

Secondly, saying it works by default is obvious since the demos work as well. Please clarify what exactly is to be passed as an argument.

var _list_print = {
      width : 250,
      height : 200,
      //template : "#title#",
      //id : '_list_print',
        view :"datatable",
        columns : [
            { id:"rank",    header:"",              width:50},
            { id:"title",   header:"Film title",    width:200},
            { id:"year",    header:"Released",      width:80},
            { id:"votes",   header:"Votes",         width:100}
        ],
        data: [
            { id:1, title:"The Shawshank Redemption", year:1994, votes:678790, rank:1},
            { id:2, title:"The Godfather", year:1972, votes:511495, rank:2}
        ]
    };

object is visible on screen ***

using the obscure reference as used in the examples (not best practice to not give an object an ID but ok, i will be lazy too) ***

var pdf = webix.toPDF(
        
         $$('$datatable1')
         ,
         {
           filename: "EsqData.pdf"
         }
         
    );

Nothing happens ***

use proper ID

var pdf = webix.toPDF(
        
         $$('_list_print')
         ,
         {
           filename: "EsqData.pdf"
         }
         
    );

Nothing happens ***

Still, something happens. Browser downloading starts and as a result you get the PDF document. Doesn’t it happen in your case?

oPDF() returns the following however: e er: null fn: null next: Array (0) No Properties. Array Prototype promise: e er: null fn: null next: Array (0) No Properties. Array Prototype promise: e {promise: e, state: “pending”, val: null, fn: null, er: null, …} state: “pending” val: null e Prototype state: “pending” val: null e Prototype

The method returns a promise object. You can, for instance, create a function that will be called once it is resolved (document downloading has finished).

Please clarify what exactly is to be passed as an argument.

The first argument is component ID (either custom, or auto-generated) while the second one contains export configuration.

Please, check the snippet: http://webix.com/snippet/aacd5c9b

Nothing is started, nothing happens. No download whatsoever.

webix.toPDF() simply does not work for us no matter what we try. We have a datable within several other containers/panels. Pretty basic stuff. The following function never gets executed. It behaves like webix.require.disabled is set to true but it is not.

return webix.require( webix.cdn + “/extras/pdfjs.js”, function () {…} );

just FYI webix.cdn does in fact point to libs location as expected. IF we alter the webix.cdn value we do get an expected not found error in console.

We can see toPDF() being called but the anonymous function passed to webix.require( path, func() ) never gets called. We placed console messages in the anonymous function just to check if we are missing something but the function is never called, ever.

We get no errors in console. When we click the button we get nothing at all. We have confirmed that the obj $$() being passed to toPDF() does in fact exist during the call.

It has been nearly a year and we have no solution so far. We have confirmed that this does work in a very simplistic example here http://webix.com/snippet/aacd5c9b but when we run the exact same code on any of our datatables we get nothing.

We are running webix v3.3 in production. We see no changes to toPDF() with current webix toPDF code in most recent code base.


    toolbar_icons[ toolbar_icons.length ] = {
        id : 'esqReportPrintBtn'
        , view : "button"
        , width : 30
        , type : "icon"
        , icon : "print"
        , tooltip : "Print Report"
        , hidden : false
        , click : function() {
            
            webix.require.disabled = false;   // just in case
            
            var id = 'esqReportViewTable';
            
            var obj = $$( id );  
            
            if ( !obj ) {

                alert('Report object '+id+' not found!');
                
            } else {

                var pdf = webix.toPDF( obj , { filename : 'EsqData' } );
               // var pdf = webix.toPDF( id , { filename : 'EsqData' } );
                
                pdf.then( function() { webix.message("Report has been downloaded"); } );
                
            }
      
        }

    };


~~~~~ here is our table def ~~~~~~~~~

var _list = {

         id              : 'esqReportViewTable'
        ,view            : 'datatable'
        ,scroll          : 'xy'
        ,select          : 'cell'
        ,scrollY         : true
        ,scrollX         : true
        ,dragColumn      : true 
        ,clipboard       : true
        ,tooltip         : true
        ,multiselect     : true
        ,navigation      : true
        ,resizeColumn    : true
        ,resizeRow       : true
        ,markSorting     : true
        ,math            : true
        ,footer          : true
        ,headerRowHeight : 28
        ,hover           : 'esqTableHover'
        ,delimiter       : { 
            rows : "\
", 
            cols : ","   
        }

    };

~~~~~~~~~~ webix toPDF() ~~~~~~~~~~

webix.toPDF = function ( i, s ) {
        
        var n = webix.promise.defer();

        return webix.require( webix.cdn + "/extras/pdfjs.js", function () {
            
/***** WE NEVER GET HERE *****/

            var r = webix.$$( i );

            s = s || {}, r.$exportView && (r = r.$exportView( s )), s.gB = "pdf", s.hB = o;
            
            var a = t( r, s ), l = e( r, s, a ), c = function ( t, e ) {
   
                var i = (e.filename || "data") + ".pdf", s = new Blob( [ t.toString() ], { type : "application/pdf" } );
                
                webix.html.download( s, i ), n.resolve()
                
            };
   
            s.hB ? h( a, l, s, c ) : pdfjs.load( webix.cdn + "/extras/pt-sans.regular.ttf", function ( t, e ) {
   
                if ( t )throw t;
   
                o = s.hB = new pdfjs.TTFFont( e ), h( a, l, s, c )
   
            } )
   
        } ), n
   
    };

Hello,

Sometimes, export scripts cannot be loaded by webix.require due to security issues in the given environment - they are loaded from the domain different from the one where your application is hosted.

To overcome it, you can download all the files needed for export locally and change the webix.cdn location to a local one.

Please, follow the guides in the documentation.