{
  "$schema": "https://ai.syncfusion.com/schema/registry-item.json",
  "name": "grid-pdf-export-template",
  "framework": "javascript",
  "type": "registry:component",
  "component": "Grid",
  "variant": "pdf-export-template",
  "dependencies": [
    "@syncfusion/ej2-grids"
  ],
  "description": "Data grid with a PDF export toolbar action and a query cell callback so templated columns export as plain text.",
  "meta": {
    "essentialStudioRelease": "2026 Volume 3 (v35.1.37)",
    "license": "commercial-or-community",
    "licenseNote": "The Syncfusion package is licensed. The composition in this file is source you own and edit. See https://ai.syncfusion.com/licensing.md",
    "requiresLicenseKey": true,
    "requiresServerEndpoint": false,
    "platformIndex": "https://ai.syncfusion.com/javascript/llms.txt",
    "skillPack": "syncfusion/javascript-ui-components-skills",
    "docs": "https://ai.syncfusion.com/gallery/javascript/grid-pdf-export-template.md"
  },
  "files": [
    {
      "target": "src/components/grid-pdf-export-template/grid.html",
      "content": "<div class=\"control-section\">\n    <div class=\"content-wrapper\">\n        <div id=\"container\"></div>\n    </div>\n</div>"
    },
    {
      "target": "src/components/grid-pdf-export-template/grid.ts",
      "content": "import { Grid, Page, Toolbar, PdfExport } from '@syncfusion/ej2-grids';\nimport { orderData } from '../datasource/grid-data';\n\nGrid.Inject(Page, Toolbar, PdfExport);\n\nconst palette: string[] = ['#6366f1', '#0ea5e9', '#10b981', '#f59e0b', '#ec4899', '#8b5cf6'];\n\nfunction prepare(): Object[] {\n    return (orderData as any[]).map((o: any) => {\n        const days: number = Math.max(0, Math.round((new Date(o.ShippedDate).getTime() - new Date(o.OrderDate).getTime()) / 86400000));\n        const s = days <= 5 ? { label: 'Fast', color: '#059669', bg: '#d1fae5' }\n            : days <= 10 ? { label: 'On time', color: '#0369a1', bg: '#e0f2fe' }\n            : { label: 'Delayed', color: '#b45309', bg: '#fef3c7' };\n        return {\n            ...o,\n            Initials: o.ShipName.trim().split(/\\s+/).map((p: string) => p[0]).slice(0, 2).join('').toUpperCase(),\n            Color: palette[[...o.CustomerID].reduce((sum: number, c: string) => sum + c.charCodeAt(0), 0) % palette.length],\n            StatusLabel: s.label, Days: days,\n            StatusText: s.label + ' · ' + days + 'd', StatusColor: s.color, StatusBg: s.bg\n        };\n    });\n}\n\nexport function initPdfExportTemplateGrid(): void {\n    const customerTemplate: string =\n        '<div style=\"display:flex;align-items:center;gap:12px\">' +\n        '<span style=\"background:${Color};width:36px;height:36px;border-radius:12px;color:#fff;display:inline-flex;align-items:center;justify-content:center;font-weight:600;font-size:13px\">${Initials}</span>' +\n        '<div style=\"display:flex;flex-direction:column;justify-content:center\">' +\n        '<span style=\"display:block;font-weight:600;color:#0f172a;line-height:20px\">${ShipName}</span>' +\n        '<span style=\"display:block;font-size:12px;color:#94a3b8;line-height:16px\">${CustomerID}</span></div></div>';\n    const statusTemplate: string =\n        '<span style=\"background:${StatusBg};color:${StatusColor};border-radius:999px;padding:2px 10px;font-size:12px;font-weight:600\">${StatusText}</span>';\n\n    const grid: Grid = new Grid({\n        dataSource: prepare(),\n        height: 440,\n        rowHeight: 60,\n        allowPaging: true,\n        pageSettings: { pageSize: 8 },\n        gridLines: 'Horizontal',\n        allowPdfExport: true,\n        toolbar: ['PdfExport'],\n        toolbarClick: (args: any) => {\n            if (args.item.id === grid.element.id + '_pdfexport') {\n                grid.pdfExport({ fileName: 'Orders.pdf' });\n            }\n        },\n        // Templates are HTML-only, so give the PDF plain text for each templated column.\n        pdfQueryCellInfo: (args: any) => {\n            const d: any = args.data;\n            if (args.column.field === 'ShipName') { args.value = d.ShipName + ' (' + d.CustomerID + ')'; }\n            if (args.column.headerText === 'Status') { args.value = d.StatusLabel + ' - ' + d.Days + ' days'; }\n        },\n        columns: [\n            { field: 'OrderID', headerText: 'Order', width: 110, isPrimaryKey: true },\n            { field: 'ShipName', headerText: 'Ship To', width: 250, template: customerTemplate },\n            { field: 'ShipCity', headerText: 'City', width: 150 },\n            { headerText: 'Status', width: 150, template: statusTemplate },\n            { field: 'Freight', headerText: 'Freight', width: 120, format: 'C2', textAlign: 'Right' }\n        ]\n    });\n    grid.appendTo('#container');\n}"
    }
  ]
}