jquery-pluginsjqgridpdfmake

jqGrid - Show Page Numbers In Export To PDF


I'm using Guriddo jqGrid JS-v5.8.2 with pdfmake 0.2.7

I can print the jqGrid to PDF, but I want the print out to show page numbers in the footer for example. Here's what I have

   $("#serialNumbersGrid").jqGrid("exportToPdf", {
     title: 'Property Serial Numbers',
     orientation: 'landscape',
     pageSize: 'A3',
     description: "Date: " + todaysDate,
     customSettings: null,
     download: 'download',
     includeLabels: true,
     includeGroupHeader: true,
     includeFooter: true,
     fileName: "SerialNumbers.pdf",   
 });

I've googled this extensively but can't find any reference to printing page numbers


Solution

  • Use onBeforeExport event to put in footer the page numbers. Actually you will need to learn pdfmake options.

       $("#serialNumbersGrid").jqGrid("exportToPdf", {
         title: 'Property Serial Numbers',
         orientation: 'landscape',
         pageSize: 'A3',
         description: "Date: " + todaysDate,
         customSettings: null,
         download: 'download',
         includeLabels: true,
         includeGroupHeader: true,
         includeFooter: true,
         fileName: "SerialNumbers.pdf",   
         onBeforeExport : function( doc) {
             doc.footer= function(currentPage, pageCount) { return currentPage.toString() + ' of ' + pageCount; 
         };
      }
     });