|
<ejs-grid #grid [dataSource]='data' allowPaging='true' [pageSettings]='pageSettings'(created)='created($event)' [toolbar]='toolbar' (toolbarClick)='toolbarClick($event)' [allowPdfExport]='true'>
</ejs-grid>
. . . . .
import {PdfPageSettings, PdfPageOrientation, PointF, SizeF, RectangleF, PdfPageTemplateElement} from '@syncfusion/ej2-pdf-export'
export class ExportingComponent implements OnInit {
. . . .
created(){
(this.grid.pdfExportModule as any).processSectionExportProperties = function (section, pdfExportProperties){
let pdfPageSettings: PdfPageSettings = new PdfPageSettings();
pdfPageSettings.orientation = PdfPageOrientation.Landscape; // you can set orientation here
pdfPageSettings.size = this.getPageSize('A4');
pdfPageSettings.margins.setMargins(10);
section.setPageSettings(pdfPageSettings);
var clientSize = pdfPageSettings.size;
if (!isNullOrUndefined(pdfExportProperties.header)) {
var header = pdfExportProperties.header, position = new PointF(0, header.fromTop), size = new SizeF(clientSize.width - 80, .75 * header.height), bounds = new RectangleF(position, size);
this.pdfDocument.template.top = this.drawPageTemplate(new PdfPageTemplateElement(bounds), header);
pdfExportProperties.header = undefined;
}
if (!isNullOrUndefined(pdfExportProperties.footer)) {
/* tslint:disable-next-line:no-any */
var footer = pdfExportProperties.footer;
var position = new PointF(0, ((clientSize.width - 80) - (footer.fromBottom * 0.75)));
var size = new SizeF((clientSize.width - 80), (footer.height * 0.75));
var bounds = new RectangleF(position, size);
this.pdfDocument.template.bottom = this.drawPageTemplate(new PdfPageTemplateElement(bounds), footer);
pdfExportProperties.footer = undefined;
}
return section;
}
}
toolbarClick(args: ClickEventArgs): void {
switch (args.item.text) {
case 'PDF Export':
let pdfExportProperties: any = {
header: {
. . . . .
{
type: 'Line',
style: { penColor: '#000000', penSize: 1, dashStyle: 'Solid' },
// change the line X2 point
points: { x1: 0, y1: 90, x2: 842*1.33, y2: 90 }
},
};
this.grid.pdfExport(pdfExportProperties);
break;
}
}
}
|