{
  "$schema": "https://ai.syncfusion.com/schema/registry-item.json",
  "name": "grid-pdf-export-template",
  "framework": "react",
  "type": "registry:component",
  "component": "Grid",
  "variant": "pdf-export-template",
  "dependencies": [
    "@syncfusion/ej2-react-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/react/llms.txt",
    "skillPack": "syncfusion/react-ui-components-skills",
    "docs": "https://ai.syncfusion.com/gallery/react/js/grid-pdf-export-template.md"
  },
  "files": [
    {
      "target": "src/components/grid-pdf-export-template/Grid.jsx",
      "content": "import { useRef } from 'react';\nimport { GridComponent, ColumnsDirective, ColumnDirective, Inject, Page, Toolbar, PdfExport } from '@syncfusion/ej2-react-grids';\nimport { orderDetails } from '../datasource/grid-data';\n\nconst palette = ['#6366f1', '#0ea5e9', '#10b981', '#f59e0b', '#ec4899', '#8b5cf6'];\nconst colorFor = (text) => palette[[...text].reduce((sum, ch) => sum + ch.charCodeAt(0), 0) % palette.length];\nconst initials = (name) => name.trim().split(/\\s+/).map((p) => p[0]).slice(0, 2).join('').toUpperCase();\nconst daysToShip = (o) => Math.max(0, Math.round((new Date(o.ShippedDate) - new Date(o.OrderDate)) / 86400000));\nconst statusOf = (days) => (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\nconst avatarStyle = { width: 36, height: 36, borderRadius: 12, color: '#fff', display: 'inline-flex', alignItems: 'center', justifyContent: 'center', fontWeight: 600, fontSize: 13 };\nconst chipStyle = { borderRadius: 999, padding: '2px 10px', fontSize: 12, fontWeight: 600 };\n\nfunction PdfExportTemplate() {\n  const gridRef = useRef(null);\n  const toolbar = ['PdfExport'];\n\n  const customerTemplate = (p) => {\n    const name = p.CustomerName.trim();\n    return (\n      <div style={{ display: 'flex', alignItems: 'center', gap: 12 }}>\n        <span style={{ ...avatarStyle, background: colorFor(p.CustomerID) }}>{initials(name)}</span>\n        <div style={{ display: 'flex', flexDirection: 'column', justifyContent: 'center' }}>\n          <span style={{ display: 'block', fontWeight: 600, color: '#0f172a', lineHeight: '20px' }}>{name}</span>\n          <span style={{ display: 'block', fontSize: 12, color: '#94a3b8', lineHeight: '16px' }}>{p.CustomerID}</span>\n        </div>\n      </div>\n    );\n  };\n  const statusTemplate = (p) => {\n    const days = daysToShip(p);\n    const s = statusOf(days);\n    return <span style={{ ...chipStyle, background: s.bg, color: s.color }}>{s.label} · {days}d</span>;\n  };\n\n  const toolbarClick = (args) => {\n    if (args.item.id === 'PdfExportTemplateGrid_pdfexport') {\n      gridRef.current?.pdfExport({ fileName: 'Orders.pdf' });\n    }\n  };\n  // Templates are HTML-only, so give the PDF plain text for each templated column.\n  const pdfQueryCellInfo = (args) => {\n    const d = args.data;\n    if (args.column.field === 'CustomerName') args.value = `${d.CustomerName.trim()} (${d.CustomerID})`;\n    if (args.column.headerText === 'Status') {\n      const days = daysToShip(d);\n      args.value = `${statusOf(days).label} - ${days} days`;\n    }\n  };\n\n  return (\n    <div className='control-pane'>\n      <div className='control-section'>\n        <GridComponent id='PdfExportTemplateGrid' ref={gridRef} dataSource={orderDetails}\n          height='440' rowHeight={60} allowPaging={true} pageSettings={{ pageSize: 8 }} gridLines='Horizontal'\n          allowPdfExport={true} toolbar={toolbar} toolbarClick={toolbarClick} pdfQueryCellInfo={pdfQueryCellInfo}>\n          <ColumnsDirective>\n            <ColumnDirective field='OrderID' headerText='Order' width='110' isPrimaryKey={true} />\n            <ColumnDirective field='CustomerName' headerText='Customer' width='230' template={customerTemplate} />\n            <ColumnDirective field='ShipCity' headerText='City' width='150' />\n            <ColumnDirective headerText='Status' width='150' template={statusTemplate} />\n            <ColumnDirective field='Freight' headerText='Freight' width='120' format='C2' textAlign='Right' />\n          </ColumnsDirective>\n          <Inject services={[Page, Toolbar, PdfExport]} />\n        </GridComponent>\n      </div>\n    </div>\n  );\n}\nexport default PdfExportTemplate;"
    }
  ]
}