2017-09-15 28 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