2016-07-25 38 views
1

我試圖使用bootstrap(shieldUI-all.min.js)將html表格數據導出爲pdf。我完成了,但我需要PDF格式的標題ie)標題在表的頂部。我不知道該怎麼做。如何使用引導程序導出html表格時在pdf中包含標題

jQuery(function ($) { 
      $("#export_supplier_pdf").click(function() { 
     // parse the HTML table element having an id=exportTable 
     var dataSource = shield.DataSource.create({ 
      data: "#table_supplier_master", 
      schema: { 
       type: "table", 
       fields: { 
        CODE: { type: String }, 
        Name: { type: String }, 
        ContactPerson: { type: String }, 
       } 
      } 
     }); 

     // when parsing is done, export the data to PDF 
     dataSource.read().then(function (data) { 
      var pdf = new shield.exp.PDFDocument({ 
       author: "GBLS", 
       created: new Date() 
      }); 

      pdf.addPage("a4", "portrait"); 

      pdf.table(
       50, 
       50, 
       data, 
       [ 
        { field: "CODE", title: "CODE", width: 200 }, 
        { field: "Name", title: "Name", width: 200 }, 
        { field: "ContactPerson", title: "ContactPerson", width: 200 } 
       ], 
       { 
        margins: { 
         top: 50, 
         left: 50 
        } 
       } 
      ); 

      pdf.saveAs({ 
       fileName: "Supplier_master" 
      }); 
     }); 
    }); 
     }); 

或其他任何方式來實現相同的東西?

回答

2

我相信目前還沒有簡單的方法與PDF選項來實現這一目標: http://www.shieldui.com/documentation/grid/javascript/api/settings/exportOptions/pdf 另一種選擇是簡單地將所需的數據添加到網格本身,因此它導出到PDF文檔。

+0

嗯我看到了,但我不知道如何完全使用導出選項,以及需要什麼樣的js文件...如果你可以附加URL,例如相同。 – mul1103

+0

您可以使用以下示例作爲起點: http://demos.shieldui.com/web/grid-general/export-to-pdf 也可以使用入門主題: http:// www .shieldui.com/documentation/grid/javascript/getting.started 其中闡述了包含的必要資源。 –

+0

我正在使用php codeigniter。那麼可以使用shieldUI來做到這一點......? – mul1103

相關問題