2017-09-15 24 views
0

我下面这个教程:http://ui-grid.info/docs/#/tutorial/206_exporting_dataAngularJS UI格导出为PDF - 页码和PDF标题也离开了,但是电网是太对

我使用angularjs UI电网。但是,当我将网格导出为pdf时,UI看起来不太好。 问题:页号和PDF标题太左,但网格太正确

我试图在网上搜索解决方案,但没有运气。这是我的网格选项设置:

gridOptions = { 
      showGridFooter: true, 
      showFooter: false, 
      enableSorting: true, 
      multiSelect: false, 
      enableFiltering: true, 
      enableRowSelection: true, 
      enableSelectAll: false, 
      enableRowHeaderSelection: false, 
      enableGridMenu: true, 
      noUnselect: true, 
      onRegisterApi: function (_gridApi) { 
       this.gridApi = _gridApi; 
      }, 
      data: [], 
      exporterCsvFilename: 'Report.csv', 
      exporterPdfDefaultStyle: {fontSize: 9}, 
      exporterPdfTableStyle: {margin: [30, 30, 30, 30]}, 
      exporterPdfTableHeaderStyle: {fontSize: 10, bold: true, italics: true, color: 'red'}, 
      exporterPdfHeader: { text: "Foo", style: 'headerStyle' }, 
      exporterPdfFooter: function (currentPage, pageCount) { 
       return { text: currentPage.toString() + ' of ' + pageCount.toString(), style: 'footerStyle' }; 
      }, 
      exporterPdfCustomFormatter: function (docDefinition) { 
       docDefinition.styles.headerStyle = { fontSize: 22, bold: true }; 
       docDefinition.styles.footerStyle = { fontSize: 10, bold: true }; 
       return docDefinition; 
      }, 
      exporterPdfOrientation: 'portrait', 
      exporterPdfPageSize: 'LETTER', 
      exporterPdfMaxGridWidth: 500, 
      exporterCsvLinkElement: angular.element(document.querySelectorAll(".custom-csv-link-location")), 
     }; 

enter image description here

回答

1

您需要保证金添加到页眉和页脚的风格,在你gridOptions,尝试这样的:

$scope.gridOptions = { 
... 
exporterPdfTableStyle: {margin: [20, 20, 20, 20]}, 
... 
exporterPdfCustomFormatter: function (docDefinition) { 
    docDefinition.styles.headerStyle = { margin: [30, 30, 30, 30],fontSize: 22, bold: true }; 
    docDefinition.styles.footerStyle = { margin: [30, 30, 30, 30],fontSize: 10, bold: true }; 
    return docDefinition; 
}, 
... 
+1

虽然你价值'边际:[20,20,20,20]'不能让我的网格在pdf中心,但你给了我这个想法。我会自己调整价值。谢谢 – EntryLeveDeveloper

+0

顺便说一句,你怎么知道这一点?我没有在他们的教程中找到解决方案? – EntryLeveDeveloper

+0

我知道css,我觉得里面的属性,我可以把任何css属性,不要担心随着时间的推移,你会做同样的:) – JoxieMedina