如何使用Angular UI grid downloadpdf函数

时间:2015-08-18 13:37:09

标签: angularjs angular-ui-grid

enter image description here

第一个paremeter是文件名,第二个是docDefinition(我将在第二个参数中传递的值)仍然混淆?

请帮帮我

1 个答案:

答案 0 :(得分:0)

第二个参数是一个具有" pdfmake"的所有选项的对象。

  

要掌握的最基本的概念是   document-definition-object,可以这么简单:

     

var docDefinition = { content: 'This is an sample PDF printed withpdfMake' };

     

或变得相当复杂(具有多级表格,   图像,列表,段落,边距,样式等......)。

您可以查看Github https://github.com/bpampuch/pdfmake上的文档,并将其复杂化。

但是如果您使用 pdfExport 功能,那么这个用数据网格创建对象,更容易,试试这个:

$scope.gridApi.exporter.pdfExport( uiGridExporterConstants.ALL, uiGridExporterConstants.ALL );

他们有更多选项可以在gridOptions中更改:

exporterPdfDefaultStyle:{ fontSize: 11 },
exporterPdfFilename: 'filename.pdf',
exporterPdfTableHeaderStyle: { bold: true, fontSize: 12, color: 'black' },
exporterPdfTableStyle : { margin: [0, 5, 0, 15] },
exporterPdfHeader : null,
exporterPdfFooter : null,
gridOptions.exporterPdfOrientation : 'landscape',

等...