Export to PDF button in service portal for list of records

anubhavr
Giga Expert

I have created a UI Action Button "Export to PDF" to export the list of Project records displaying in the Service Portal Widget in the form of table. When the number of records are less like 10-15 records only that it is working correctly but for more than 15-16 records only Black PDF is downloaded. How can this issue be resolved?

this is my Client Controller script:

$scope.exportPDF = function() {

html2canvas(document.getElementById('tableProjects'),{

                      onrendered: function (canvas) {

                              var data = canvas.toDataURL();

                              var docDefinition = {

                                      content: [{

                                              image: data,

                                              width: 50000,

height: 50000

                                      }]

                              };

                              pdfMake.createPdf(docDefinition).download("Projects.pdf");

                      }

});

};

12 REPLIES 12

Rushit Patel2
Tera Guru

on your export link you need to build below url



<a ng-href="/{{data.table}}_list.do?PDF&sysparm_query={{data.filter}}&sysparm_view={{data.view}}" target="_new">${Export as} {{::t.label}}</a>



in above you need to pass 3 things



data.table --> i guess it will be name of project table


data.view --> view you need to export


data.filter --> query of which projects you want to export.



(please mark correct/helpful if it helped)


Hi Rushit,



Thanks for the response. This was helpful but in my case I don't think this will work. I want only particular Fields to be present in the PDF and in same order as it is present in my Portal page.



My portal page URL is also different:



www.xyz.service-now.com/ppm/$sp.do?id=project_status_index&portfolio_sys_id=b28f3065dba5f600c451d79b5e9619ab&program_sys_id=2d5489fadbe13e001ab6591e5e961930



please find the screenshot for my Portal page:



project status index portal page.PNG




This data are not collected from a particular table, this is collected from Project and Project status table together. We want PDF of these list of records only with same columns and same order.



Please help me if possible.




Regards,


Anubhav


I even tried adding PDF in my URL but it don't download any PDF on adding PDF in my URL as u mentioned in your URL.


so how that list is displayed right now...are you not using Out of box "list" widget?