Posted 13 September 2024, 4:21 am EST
Hi, I’m trying to setup a simple PDF export from a grid.
- I need to be able to choose which columns to include, with autoexpand and the ability change header visibility. With the code below, this works.
But I am struggling with the format of the export.
When I hide columns, I need the grid to autoexpand the remaining columns, not increase the font in the export. I.e if the export contains to many columns the complete text does not show, If I reduce the number of columns that I export, the export just increases the font size of the document automatically, I want the keep the font, and hopefully the remaining columns get wider and the complete text of the column is shown.
Is there a easy way to keep the font sizes and format of the document when removing columns from the export so that the remaining columns gets wider?
This is the code I’m using.
var theGrid = GridAPI.GridManager.GetGridById($parameters.gridid)._provider;
const view = theGrid.collectionView;
var oldPgSize = view.pageSize;
var oldPgIndex = view.pageIndex;
if($parameters.PrintAllPages=true){
//gjør dette for å sette ny pageindex for å laste ned hele griden (med paginering)
theGrid.beginUpdate();
// 0 her betyr alle
view.pageSize = 0;
}
theGrid.autoSizeColumns();
theGrid.headersVisibility = 1;
wijmo.grid.pdf.FlexGridPdfConverter.export(theGrid, $parameters.HeaderText.replace(' ', '') + '_'+$parameters.TitleText.replace(' ', '_')+'.pdf', {
scaleMode: wijmo.grid.pdf.ScaleMode.PageWidth,
maxPages: 99,
documentOptions: {
info: {title: $parameters.HeaderText },
pageSettings: {
layout : $parameters.LandscapeLayout,
size : 3
},
header: { declarative: { text: $parameters.HeaderText } },
footer: { declarative: { text: '\t&[Page]\\&[Pages]' } },
},
styles: {
cellStyle: {
backgroundColor: '#ffffff',
borderColor: '#ffffff',
font: {
size: 15
}
},
headerCellStyle: {
backgroundColor: '#ffffff',
font: {
size: 15
}
}
},
});
if($parameters.PrintAllPages=true){
view.pageSize = oldPgSize;
view.moveToPage(oldPgIndex);
theGrid.endUpdate();
}
theGrid.headersVisibility = 3;