AngularJS ui网格导出为pdf-页码和pdf标题太左,但网格太右
我将学习本教程: 我正在使用angularjs ui网格。但当我将网格导出到pdf时,UI看起来不太好。 问题:页码和Pdf标题太左,但网格太右 我试图在网上搜索解决方案,但没有成功。这是我的网格选项设置:AngularJS ui网格导出为pdf-页码和pdf标题太左,但网格太右,angularjs,angular-ui-grid,Angularjs,Angular Ui Grid,我将学习本教程: 我正在使用angularjs ui网格。但当我将网格导出到pdf时,UI看起来不太好。 问题:页码和Pdf标题太左,但网格太右 我试图在网上搜索解决方案,但没有成功。这是我的网格选项设置: gridOptions = { showGridFooter: true, showFooter: false, enableSorting: true, multiSelect: false,
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")),
};
您需要在页眉和页脚样式中添加边距,在
网格选项中,尝试以下操作:
$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;
},
...
虽然你的价值‘margin:[20,20,20,20]’无法在pdf中心生成我的网格,但你给了我这个想法。我将自己调整值。谢谢顺便问一下,你怎么知道的?我没有找到他们的教程中的解决方案?我知道CSS,我想在那个属性里面我可以放置任何CSS属性,不用担心,随着时间的推移,你会做同样的事情:谢谢,我感谢你所有的帮助,现在网格可以在中间。但是页眉和页脚(页面)无法工作。你可以试试这个: