问题
I want to add an image to the header of the pdf.
I am trying to add the image, which I converted to base 64, to exporterPdfHeader.
$scope.gmGrid.exporterPdfHeader = {
margin: [30, 5, 30, 15],
table: {
widths: [ '*', '*' ],
body: [
[ 'MC #: ' + $scope.mc, 'Week Ending Date: ' + $scope.weekEndDate ],
],
//ADD IMAGE
myImage: 'data:image/false;base64,iVBORw0KGgoAAAANSUhEUgAAAIgAAAAkCAYAAABSZHLHAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAA3NpVFh0WE1MOmNvbS5hZG9iZS54bXAAAAAAADw/eHBhY2tldCBiZWdpbj0i77u/IiBpZD0iVzVNME1wQ2VoaUh6cmVTek5UY3prYzlkIj8+IDx4OnhtcG1ldGEgeG1sbnM6eD0iYWRvYmU6bnM6bWV0YS8iIHg6eG1wdGs9IkFkb2JlIFhNUCBDb3JlIDUuNS1jMDE0IDc5LjE1MTQ4MSwgMjAxMy8wMy8xMy0xMjowOToxNSAgICAgICAgIj4gPHJkZjpSREYgeG1sbnM6cmRmPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5LzAyLzIyLXJkZi1zeW50YXgtbnMjIj4gPHJkZjpEZXNjcmlwdGlvbiByZGY6YWJvdXQ9IiIgeG1sbnM6eG1wTU09Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC9tbS8iIHhtbG5zOnN0UmVmPSJodHRwOi8vbnMuYWRvYmUuY29tL3hhcC8xLjAvc1R5cGUvUmVzb3VyY2VSZWYjIiB4bWxuczp4bXA9Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC8iIHhtcE1NOk9yaWdpbmFsRG9jdW1lbnRJRD0ieG1wLmRpZDozYzllOTA5MC00MTAyLTQ3ZGMtYWVlNy02MjQyZjY0ODNiN2UiIHhtcE1NOkRvY3VtZW50SUQ9InhtcC5kaWQ6QjhFMDBBNkE2QzQyMTFFNTk3NEQ4QjhGODU4MkQ4QjciIHhtcE1NOkluc3Rhb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OAEzSiPMPQI1z8dcb/tbHw9c8+BDGrR7mHdDNrgTfRjOrHAIta0P6SJ9DDKeIHejR/Yz99Q+DZK+AQl73pC3IUk5dO5jybVD3AvfUh4OnvrxvLvx2g2ecc+zm/jXCXJM96Rt8m68BhKNH2Y2CeLON0fOPeAuX4RPYpC/BbiKeQ45JGwP5wK+V1MGe3hcmKze9xfTN5QxLFmXOFk2NqYRdyrRsgjEap73F9Og6kfZfRgxVV4n8ZA7E4RDipRwj5IY78fz7xtKL07JN5PMP0R97i/j/2PZT+NKHgSBGjifn7gftVc0845dj0VrEc9Td/ikjEv31l2WrsIMtnq91+RHEhiC5Goq8e+GiPI2YO438VkIkg8hnm0nTLXExWUdPn9S/oHnoNNKdDUK/HW+4ZycfzDqeM89I0xfXPMfR7ImP9nkNWH/f7rxHN8FC8YNZoI48/hvc7xon/n4t6vacl33TFBjhM57F/biGtL9y8Tcrwtorw/iKLvI39qNom8ht33ewNPyccGrttg8q6YICczKQbpwF7S4/lfoFNaHNL9vJvKZwfeoyekCXcj3uQqUy2p11jjHfuKZ0yQk5gQdkyiv3Gld+QdWNcGUTLom3H3kmS2ZWjSqYdZS0XoEtvVVH3lJMQtxuvEBDmJyZGgMajPY+pMw1GbiNppvR3FNgaqnkxDQ88TEGQ7LYoOGpL67usqyvKemCAnLzmmUnJ+2DvSodUw8idv4OnqViy9dwhLaDIthbXM1cncj5lyPQ4xJxk5tM+hDcZFhBR94KYNsXXkFn9HeYe9/J5c9+Md1kE29yJWA/C8PF5ziAkyfJ6jEmLoy8ra8NO35/WB5fOQordAS/GpWh6iBPbyJcVRcTH+L6jiMdj4rwADACwl88uwU7JvAAAAAElFTkSuQmCC',
width: 150,
height: 150,
},
},
There is no error in the console. Not sure what I am missing. Any help is appreciated.
UPDATE***
I added in the column with the image inside exporterPdfHeader, but when I do this it does not show the header which is contained in the body. It just shows the image and the table.
$scope.gridOptions.exporterPdfHeader ={
//title: 'test',
//LOGO TEST (causes the header to disappear..
columns: [{
image: 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GwP5wK+V1MGe3hcmKze9xfTN5QxLFmXOFk2NqYRdyrRsgjEap73F9Og6kfZfRgxVV4n8ZA7E4RDipRwj5IY78fz7xtKL07JN5PMP0R97i/j/2PZT+NKHgSBGjifn7gftVc0845dj0VrEc9Td/ikjEv31l2WrsIMtnq91+RHEhiC5Goq8e+GiPI2YO438VkIkg8hnm0nTLXExWUdPn9S/oHnoNNKdDUK/HW+4ZycfzDqeM89I0xfXPMfR7ImP9nkNWH/f7rxHN8FC8YNZoI48/hvc7xon/n4t6vacl33TFBjhM57F/biGtL9y8Tcrwtorw/iKLvI39qNom8ht33ewNPyccGrttg8q6YICczKQbpwF7S4/lfoFNaHNL9vJvKZwfeoyekCXcj3uQqUy2p11jjHfuKZ0yQk5gQdkyiv3Gld+QdWNcGUTLom3H3kmS2ZWjSqYdZS0XoEtvVVH3lJMQtxuvEBDmJyZGgMajPY+pMw1GbiNppvR3FNgaqnkxDQ88TEGQ7LYoOGpL67usqyvKemCAnLzmmUnJ+2DvSodUw8idv4OnqViy9dwhLaDIthbXM1cncj5lyPQ4xJxk5tM+hDcZFhBR94KYNsXXkFn9HeYe9/J5c9+Md1kE29yJWA/C8PF5ziAkyfJ6jEmLoy8ra8NO35/WB5fOQordAS/GpWh6iBPbyJcVRcTH+L6jiMdj4rwADACwl88uwU7JvAAAAAElFTkSuQmCC',
width: 150
}],
margin: [30, 5, 30, 15],
table: {
widths: [ '*', '*', '*' /*, '*'*/ ],
body: [
[ 'Region: ' + $scope.region, 'Group: ' + $scope.group, 'MC: ' + $scope.mc /*, 'The last one'*/ ],
[ 'District #: ' + $scope.district, 'Route #: ' + $scope.route, 'Week Ending Date: ' + $scope.weekEndDate, /*, 'Value 4' */],
]
},
};
回答1:
This should get you started:
And here's the relevant angularJS code:
$scope.export = function() {
var exportData = [];
var exportColumnHeaders = $scope.gridOptions.showHeader ? uiGridExporterService.getColumnHeaders($scope.gridApi.grid, uiGridExporterConstants.VISIBLE) : [];
angular.forEach($scope.gridApi.grid.rows, function(row) {
if (row.visible) {
var values = [];
angular.forEach(exportColumnHeaders, function(column) {
var value = row.entity[column.name];
if (column.name == 'rentalCreditPercentTues') value = $filter('percentFilter')(value);
values.push({
value: value
});
});
exportData.push(values);
}
});
var content = uiGridExporterService.prepareAsPdf($scope.gridApi.grid, exportColumnHeaders, exportData);
content.pageMargins = [40, 80, 40, 60];
pdfMake.createPdf(content).open();
};
$scope.gridOptions = {
exporterPdfHeader: {
margin: 20,
columns: [{
image: 'data:image/false;base64,iVBORw0KGgoAAAANSUhEUgAAAIgAAAAkCAYAAABSZHLHAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAA3NpVFh0WE1MOmNvbS5hZG9iZS54bXAAAAAAADw/eHBhY2tldCBiZWdpbj0i77u/IiBpZD0iVzVNME1wQ2VoaUh6cmVTek5UY3prYzlkIj8+IDx4OnhtcG1ldGEgeG1sbnM6eD0iYWRvYmU6bnM6bWV0YS8iIHg6eG1wdGs9IkFkb2JlIFhNUCBDb3JlIDUuNS1jMDE0IDc5LjE1MTQ4MSwgMjAxMy8wMy8xMy0xMjowOToxNSAgICAgICAgIj4gPHJkZjpSREYgeG1sbnM6cmRmPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5LzAyLzIyLXJkZi1zeW50YXgtbnMjIj4gPHJkZjpEZXNjcmlwdGlvbiByZGY6YWJvdXQ9IiIgeG1sbnM6eG1wTU09Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC9tbS8iIHhtbG5zOnN0UmVmPSJodHRwOi8vbnMuYWRvYmUuY29tL3hhcC8xLjAvc1R5cGUvUmVzb3VyY2VSZWYjIiB4bWxuczp4bXA9Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC8iIHhtcE1NOk9yaWdpbmFsRG9jdW1lbnRJRD0ieG1wLmRpZDozYzllOTA5MC00MTAyLTQ3ZGMtYWVlNy02MjQyZjY0ODNiN2UiIHhtcE1NOkRvY3Vt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D5Cn2DWkmCfphb+Ykwysxz0WuAfiLSd0L0d5Yd1UDeNfonLJt5xtyCefC1Ok9id+Tj9hIT2DGshTj2BTuOAEzSiPMPQI1z8dcb/tbHw9c8+BDGrR7mHdDNrgTfRjOrHAIta0P6SJ9DDKeIHejR/Yz99Q+DZK+AQl73pC3IUk5dO5jybVD3AvfUh4OnvrxvLvx2g2ecc+zm/jXCXJM96Rt8m68BhKNH2Y2CeLON0fOPeAuX4RPYpC/BbiKeQ45JGwP5wK+V1MGe3hcmKze9xfTN5QxLFmXOFk2NqYRdyrRsgjEap73F9Og6kfZfRgxVV4n8ZA7E4RDipRwj5IY78fz7xtKL07JN5PMP0R97i/j/2PZT+NKHgSBGjifn7gftVc0845dj0VrEc9Td/ikjEv31l2WrsIMtnq91+RHEhiC5Goq8e+GiPI2YO438VkIkg8hnm0nTLXExWUdPn9S/oHnoNNKdDUK/HW+4ZycfzDqeM89I0xfXPMfR7ImP9nkNWH/f7rxHN8FC8YNZoI48/hvc7xon/n4t6vacl33TFBjhM57F/biGtL9y8Tcrwtorw/iKLvI39qNom8ht33ewNPyccGrttg8q6YICczKQbpwF7S4/lfoFNaHNL9vJvKZwfeoyekCXcj3uQqUy2p11jjHfuKZ0yQk5gQdkyiv3Gld+QdWNcGUTLom3H3kmS2ZWjSqYdZS0XoEtvVVH3lJMQtxuvEBDmJyZGgMajPY+pMw1GbiNppvR3FNgaqnkxDQ88TEGQ7LYoOGpL67usqyvKemCAnLzmmUnJ+2DvSodUw8idv4OnqViy9dwhLaDIthbXM1cncj5lyPQ4xJxk5tM+hDcZFhBR94KYNsXXkFn9HeYe9/J5c9+Md1kE29yJWA/C8PF5ziAkyfJ6jEmLoy8ra8NO35/WB5fOQordAS/GpWh6iBPbyJcVRcTH+L6jiMdj4rwADACwl88uwU7JvAAAAAElFTkSuQmCC',
width: 150
}]
}
};
The trick is creating enough space in the page header using the pageMargins
.
Here's the all important Plunker, http://plnkr.co/edit/1rL7ZBPu9mPym8SEjMxe?p=preview.
Let me know if you need anymore help.
回答2:
i was able to export an image within exporterPdfHeader function:
$scope.gridOptions.exporterPdfHeader = {
columns: [
{
margin: [0, 0, 0, 0],
image: 'base64 url',
width: 200,
height: 58,
},
{
margin: [0, 0, 0, 0],
table: {
widths: [ '*', '*', '*' ],
body: [
....
]
}
}
]
};
来源:https://stackoverflow.com/questions/42981314/angular-ui-grid-exporting-an-image-to-a-pdf