src/ui/grid/pdf-export/smart-grid-pdf-export.component.ts
Component that renders a table for PDF export of grid data, avoiding selection highlighting issues.
| changeDetection | ChangeDetectionStrategy.Eager |
| encapsulation | ViewEncapsulation.None |
| selector | smart-grid-pdf-export |
| styleUrls | ./smart-grid-pdf-export.component.scss |
| templateUrl | ./smart-grid-pdf-export.component.html |
Properties |
Methods |
|
Inputs |
| columns |
Type : any[]
|
Default value : []
|
|
The column configuration for the table |
| data |
Type : any[]
|
Default value : []
|
|
The data to be displayed in the PDF |
| fileName |
Type : string
|
Default value : 'Export.pdf'
|
|
The file name for the exported PDF |
| gridImages |
Type : any
|
|
Grid images configuration for image columns |
| landscape |
Type : boolean
|
Default value : false
|
|
Whether to use landscape orientation |
| margin |
Type : any
|
Default value : {
top: '1cm',
right: '1cm',
bottom: '2cm',
left: '1cm'
}
|
|
Margins for the PDF |
| paperSize |
Type : string
|
Default value : 'A4'
|
|
The paper size for the PDF |
| repeatHeaders |
Type : boolean
|
Default value : true
|
|
Whether to repeat headers on each page |
| reportFooterTemplate |
Type : string
|
|
The footer template for the PDF |
| reportTitleTemplate |
Type : string
|
|
The title template for the PDF |
| scale |
Type : number
|
Default value : 0.8
|
|
Scale factor for the PDF |
| shouldTruncateText |
Type : boolean
|
Default value : true
|
|
Whether to truncate text |
| showDateTimeZone |
Type : boolean
|
Default value : true
|
|
Whether DATETIME-TZ timezone badges/selectors are displayed. |
| useDateTimeZones |
Type : boolean
|
Default value : true
|
|
Whether DATETIME-TZ offsets should be displayed. |
| Public exportPDF |
exportPDF()
|
|
Exports the table content as a PDF
Returns :
void
|
| Public processTemplate | ||||||||||||||||
processTemplate(template: string, pageNum?: number, totalPages?: number)
|
||||||||||||||||
|
Processes a template string with placeholders
Parameters :
Returns :
string
The processed template string |
| pdfExport |
Type : PDFExportComponent
|
Decorators :
@ViewChild('pdfExport', {static: false})
|
|
Reference to the Kendo PDF export component |
<!--
**************************************************************************
* Copyright © 2006-2026 by Consultingwerk Ltd. ("CW") - *
* www.consultingwerk.com and other contributors as listed *
* below. All Rights Reserved. *
* *
* Software is distributed on an "AS IS", WITHOUT WARRANTY OF ANY *
* KIND, either express or implied. *
* *
* Contributors: *
* *
**************************************************************************
--------------------------------------------------------------------------
File : smart-grid-pdf-export.component.html
Purpose : Template for Smart Grid Pdf Export.
Author(s) : Radu Nicoara
Created : May 08, 2025
--------------------------------------------------------------------------
-->
<div class="smart-grid-pdf-export-container">
<kendo-pdf-export #pdfExport
[fileName]="fileName"
[paperSize]="paperSize"
[landscape]="landscape"
[scale]="scale"
[repeatHeaders]="repeatHeaders"
[margin]="margin">
<div class="smart-grid-pdf-content">
@if (reportTitleTemplate) {
<div class="smart-grid-pdf-title mb-4">
{{ processTemplate(reportTitleTemplate) }}
</div>
}
<table class="smart-grid-pdf-table">
<thead>
<tr>
@for (column of columns || []; track column.field) {
<th
[attr.data-field]="column.field"
class="smart-grid-pdf-header-cell">
{{column.title || ''}}
</th>
}
</tr>
</thead>
<tbody>
@if (data && data.length > 0) {
@for (dataItem of data; track $index) {
<tr class="smart-grid-pdf-row">
@for (column of columns || []; track column.field) {
<td class="smart-grid-pdf-cell">
<smart-grid-cell
[column]="column"
[dataItem]="dataItem"
[gridImages]="gridImages"
[shouldTruncateText]="shouldTruncateText"
[showDateTimeZone]="showDateTimeZone"
[useDateTimeZones]="useDateTimeZones"
></smart-grid-cell>
</td>
}
</tr>
}
} @else {
<tr class="smart-grid-pdf-row">
<td [attr.colspan]="(columns || []).length" class="smart-grid-pdf-cell smart-grid-pdf-no-data">
No records available
</td>
</tr>
}
</tbody>
</table>
</div>
<ng-template kendoPDFTemplate let-pageNum="pageNum" let-totalPages="totalPages">
<div class="smart-grid-pdf-page-template">
@if (reportFooterTemplate) {
<div class="smart-grid-pdf-page-number">
{{ processTemplate(reportFooterTemplate, pageNum, totalPages) }}
</div>
} @else {
<div class="smart-grid-pdf-page-number">
Page {{pageNum}} of {{totalPages}}
</div>
}
</div>
</ng-template>
</kendo-pdf-export>
</div>
./smart-grid-pdf-export.component.scss
/**********************************************************************
* Copyright © 2006-2026 by Consultingwerk Ltd. ("CW") - *
* www.consultingwerk.com and other contributors as listed *
* below. All Rights Reserved. *
* *
* Software is distributed on an "AS IS", WITHOUT WARRANTY OF ANY *
* KIND, either express or implied. *
* *
* Contributors: *
* *
**********************************************************************/
/*------------------------------------------------------------------------
File : smart-grid-pdf-export.component.scss
Purpose : Styles for Smart Grid Pdf Export.
Author(s) : Radu Nicoara
Created : May 08, 2025
----------------------------------------------------------------------*/
.smart-grid-pdf-export-container {
position: absolute;
left: -9999px;
top: -9999px;
z-index: -1;
visibility: hidden;
opacity: 0;
width: 800px;
overflow: visible;
background-color: white;
min-height: 1000px;
}
.smart-grid-pdf-content {
font-family: Arial, Helvetica, sans-serif;
background-color: white;
width: 100%;
padding: 20px;
box-sizing: border-box;
min-height: 500px;
}
.smart-grid-pdf-table {
width: 100%;
border-collapse: collapse;
table-layout: fixed;
background-color: white;
}
.smart-grid-pdf-header-cell {
background-color: #f6f6f6;
color: #000000;
font-weight: bold;
padding: 8px;
border: 1px solid #dddddd;
text-align: left;
font-size: 12px;
}
.smart-grid-pdf-cell {
padding: 8px;
border: 1px solid #dddddd;
text-align: left;
font-size: 11px;
vertical-align: middle;
word-wrap: break-word;
max-width: 300px;
background-color: inherit;
height: auto;
min-height: 20px;
}
.smart-grid-pdf-no-data {
text-align: center;
font-style: italic;
color: #777;
padding: 20px;
}
.smart-grid-pdf-row:nth-child(even) {
background-color: #f9f9f9;
}
.smart-grid-pdf-image {
max-width: 32px;
max-height: 32px;
display: block;
margin: 0 auto;
}
.smart-grid-pdf-boolean {
display: flex;
justify-content: center;
align-items: center;
width: 100%;
text-align: center;
}
.smart-grid-pdf-boolean-true {
color: green;
}
.smart-grid-pdf-boolean-false {
color: red;
}
.smart-grid-pdf-page-number {
position: absolute;
bottom: 30px;
left: 30px;
right: 30px;
text-align: center;
color: #888;
font-size: 10px;
}
kendo-pdf-export {
position: static !important;
visibility: visible !important;
width: 100% !important;
height: auto !important;
overflow: visible !important;
display: block !important;
background-color: white !important;
}
.smart-grid-pdf-row {
page-break-inside: avoid;
height: auto;
min-height: 30px;
}