Hi Jiang,
Thanks for contacting Syncfusion support.
To export the pivot table data to PDF from Pivot in single
page, please refer to the following code example and reference sample to
customize column width while pdf export using pivot table component instance.
|
let pivotObj: PivotView = new PivotView({
.
. .
dataBound: function() {
if (isInit) {
isInit = false;
pivotObj.grid.pdfQueryCellInfo = pdfQueryCellInfo.bind(this);
}
}
});
pivotObj.appendTo('#PivotView');
function pdfQueryCellInfo(args) {
(pivotObj.renderModule as any).pdfRowEvent(args);
const pdfColumns = args.cell.gridRow.pdfGrid.columns.internalColumns;
if (pdfColumns._widthWasFitToPage) return;
let gridWidth = 0;
pdfColumns.forEach((col) => {
gridWidth += col.width;
});
const pageWidthPixels = 500;
const widthRatio = Math.min(1, pageWidthPixels / gridWidth);
pdfColumns.forEach((pdfColumn) => {
pdfColumn.width *= widthRatio;
pdfColumn._widthWasFitToPage = true;
});
pdfColumns._widthWasFitToPage = true;
}
|
Sample: https://stackblitz.com/edit/kjjas4?file=index.html,index.ts
Please let us know if any concern occurs.
Regards,
Sastha Prathap S.