|
| 1 | +<div class="sample-wrapper"> |
| 2 | + <h2 class="sample-title">PDF Export Service Demo</h2> |
| 3 | + <p class="sample-description"> |
| 4 | + This demo shows how to use the IgxPdfExporterService API directly to export grids to PDF format. |
| 5 | + Configure the export options using the controls below and click the export buttons. |
| 6 | + </p> |
| 7 | + |
| 8 | + <!-- Export Configuration Panel --> |
| 9 | + <div class="config-panel"> |
| 10 | + <h3>Export Options Configuration</h3> |
| 11 | + |
| 12 | + <div class="config-row"> |
| 13 | + <igx-input-group> |
| 14 | + <label igxLabel>File Name</label> |
| 15 | + <input igxInput type="text" [(ngModel)]="fileName" /> |
| 16 | + </igx-input-group> |
| 17 | + </div> |
| 18 | + |
| 19 | + <div class="config-row"> |
| 20 | + <igx-input-group> |
| 21 | + <label igxLabel>Page Orientation</label> |
| 22 | + <igx-select [(ngModel)]="pageOrientation"> |
| 23 | + <igx-select-item value="portrait">Portrait</igx-select-item> |
| 24 | + <igx-select-item value="landscape">Landscape</igx-select-item> |
| 25 | + </igx-select> |
| 26 | + </igx-input-group> |
| 27 | + </div> |
| 28 | + |
| 29 | + <div class="config-row"> |
| 30 | + <igx-input-group> |
| 31 | + <label igxLabel>Page Size</label> |
| 32 | + <igx-select [(ngModel)]="pageSize"> |
| 33 | + @for (size of pageSizes; track size) { |
| 34 | + <igx-select-item [value]="size">{{ size.toUpperCase() }}</igx-select-item> |
| 35 | + } |
| 36 | + </igx-select> |
| 37 | + </igx-input-group> |
| 38 | + </div> |
| 39 | + |
| 40 | + <div class="config-row"> |
| 41 | + <igx-input-group> |
| 42 | + <label igxLabel>Font Size</label> |
| 43 | + <input igxInput type="number" [(ngModel)]="fontSize" min="8" max="16" /> |
| 44 | + </igx-input-group> |
| 45 | + </div> |
| 46 | + |
| 47 | + <div class="config-row"> |
| 48 | + <igx-switch [(ngModel)]="showTableBorders">Show Table Borders</igx-switch> |
| 49 | + </div> |
| 50 | + </div> |
| 51 | + |
| 52 | + <!-- Regular Grid --> |
| 53 | + <div class="grid-container"> |
| 54 | + <div class="grid-header"> |
| 55 | + <h3>Regular Grid</h3> |
| 56 | + <button igxButton="contained" (click)="exportGrid()"> |
| 57 | + Export to PDF |
| 58 | + </button> |
| 59 | + </div> |
| 60 | + |
| 61 | + <igx-grid #grid1 [data]="gridData" [autoGenerate]="false" height="400px" width="100%"> |
| 62 | + <igx-column field="ID" header="ID" [width]="'80px'"></igx-column> |
| 63 | + <igx-column field="Name" header="Product Name" [width]="'200px'"></igx-column> |
| 64 | + <igx-column field="Category" header="Category" [width]="'150px'"></igx-column> |
| 65 | + <igx-column field="Price" header="Price" dataType="currency" [width]="'120px'"></igx-column> |
| 66 | + <igx-column field="InStock" header="In Stock" dataType="boolean" [width]="'100px'"></igx-column> |
| 67 | + <igx-column field="LaunchDate" header="Launch Date" dataType="date" [width]="'150px'"></igx-column> |
| 68 | + </igx-grid> |
| 69 | + </div> |
| 70 | + |
| 71 | + <!-- Tree Grid --> |
| 72 | + <div class="grid-container"> |
| 73 | + <div class="grid-header"> |
| 74 | + <h3>Tree Grid (with Hierarchy)</h3> |
| 75 | + <button igxButton="contained" (click)="exportTreeGrid()"> |
| 76 | + Export to PDF |
| 77 | + </button> |
| 78 | + </div> |
| 79 | + |
| 80 | + <igx-tree-grid #treeGrid [data]="treeGridData" [autoGenerate]="false" |
| 81 | + primaryKey="ID" foreignKey="ParentID" height="400px" width="100%"> |
| 82 | + <igx-column field="ID" header="ID" [width]="'100px'"></igx-column> |
| 83 | + <igx-column field="Name" header="Department Name" [width]="'300px'"></igx-column> |
| 84 | + <igx-column field="Budget" header="Budget" dataType="currency" [width]="'150px'"></igx-column> |
| 85 | + </igx-tree-grid> |
| 86 | + </div> |
| 87 | + |
| 88 | + <!-- Hierarchical Grid --> |
| 89 | + <div class="grid-container"> |
| 90 | + <div class="grid-header"> |
| 91 | + <h3>Hierarchical Grid</h3> |
| 92 | + <button igxButton="contained" (click)="exportHierarchicalGrid()"> |
| 93 | + Export to PDF |
| 94 | + </button> |
| 95 | + </div> |
| 96 | + |
| 97 | + <igx-hierarchical-grid #hierarchicalGrid [data]="hierarchicalGridData" |
| 98 | + [autoGenerate]="false" height="400px" width="100%"> |
| 99 | + <igx-column field="ID" header="ID" [width]="'80px'"></igx-column> |
| 100 | + <igx-column field="CompanyName" header="Company" [width]="'250px'"></igx-column> |
| 101 | + <igx-column field="Revenue" header="Revenue" dataType="currency" [width]="'150px'"></igx-column> |
| 102 | + |
| 103 | + <igx-row-island [key]="'Employees'" [autoGenerate]="false"> |
| 104 | + <igx-column field="ID" header="Employee ID" [width]="'120px'"></igx-column> |
| 105 | + <igx-column field="Name" header="Name" [width]="'200px'"></igx-column> |
| 106 | + <igx-column field="Position" header="Position" [width]="'150px'"></igx-column> |
| 107 | + <igx-column field="Salary" header="Salary" dataType="currency" [width]="'120px'"></igx-column> |
| 108 | + </igx-row-island> |
| 109 | + </igx-hierarchical-grid> |
| 110 | + </div> |
| 111 | + |
| 112 | + <div class="info-section"> |
| 113 | + <h4>How to Use:</h4> |
| 114 | + <ol> |
| 115 | + <li>Configure the export options using the controls at the top</li> |
| 116 | + <li>Click any of the "Export to PDF" buttons to export the corresponding grid</li> |
| 117 | + <li>The PDF will be downloaded with your configured settings</li> |
| 118 | + <li>Tree and Hierarchical grids will show indentation in the exported PDF</li> |
| 119 | + </ol> |
| 120 | + |
| 121 | + <h4>Key Features:</h4> |
| 122 | + <ul> |
| 123 | + <li><strong>Direct API Usage:</strong> Uses IgxPdfExporterService.export() method directly</li> |
| 124 | + <li><strong>Configurable Options:</strong> Adjust orientation, page size, font size, and borders</li> |
| 125 | + <li><strong>Hierarchy Support:</strong> Tree and Hierarchical grids export with proper indentation</li> |
| 126 | + <li><strong>Multiple Grids:</strong> Export different grid types with the same configuration</li> |
| 127 | + </ul> |
| 128 | + </div> |
| 129 | +</div> |
0 commit comments