Cell padding when exporting to PDF

How to custom the cell padding when exporting to PDF? 


3 Replies

KK Konduru Keerthi Konduru Ravichandra Raju Syncfusion Team June 14, 2022 11:37 AM UTC

Hi Belle,


Greetings from Syncfusion.


We suggest you to use IndentLevel property of CellStyle to set required indent in Excel cell before converting to PDF. Pease find the code snippet below.


Code Snippet:


//Text Indent Setting

worksheet.Range["C6"].CellStyle.IndentLevel = 6;


Kindly try and let us know if this helps.


Regards,

Keerthi.



BP Belle Perez June 15, 2022 02:07 AM UTC

Thanks for the fast reply Keerthi,


But I want to export pdf from the grid. How to custom the cell padding of pdf export?



PS Pavithra Subramaniyam Syncfusion Team June 15, 2022 09:29 AM UTC

Hi Belle Perez,


You can customize the pdf cell padding in Grid exporting by setting the “cellPadding” property inside the “pdfQueryCellInfo” event. Please refer to the below code example and API link for more information.


<ejs-grid id="Grid" dataSource="ViewBag.datasource" allowPdfExport="true" toolbarClick="toolbarClick"

                      pdfQueryCellInfo="pdfQueryCellInfo" toolbar="@(new List<string>() { "PdfExport" })" height="350">

                <e-grid-columns>

                    .  .  .

                </e-grid-columns>

            </ejs-grid>

 

<script>

function pdfQueryCellInfo(args) {

  args.style = { cellPadding: new ej.pdfexport.PdfPaddings(10101010) };

}

</script>


API: https://ej2.syncfusion.com/javascript/documentation/api/grid/pdfQueryCellInfoEventArgs/


Please get back to us if you need further assistance on this.


Regards,

Pavithra S


Loader.
Up arrow icon