Cell padding when exporting to PDF

How to custom the cell padding when exporting to PDF?


1 Reply

SP Sarveswaran Palani Syncfusion Team June 23, 2022 12:04 PM UTC

Hi Belle,


Thanks for contacting Syncfusion support.


We have analyzed your query and created sample based on your requirement using PdfGridCellType method. You can export all the columns in a single page by AllowHorizontalOverFlow property of ExportProperties as false. Kindly refer the attached code snippet and sample for your reference.


public void PdfQueryCellInfoHandler(PdfQueryCellInfoEventArgs<Order> args)

    {

        if(args.Column.HeaderText == "Customer ID")

        {

            string input= args.Cell.Value.ToString();

            Regex tagRegex = new Regex(@"<[^>]+>");

            bool hasTags = tagRegex.IsMatch(input);

            if (hasTags)

            {

                PdfGridCellStyle pdfGridCellStyle = new PdfGridCellStyle();

                pdfGridCellStyle.CellPadding = new PdfPaddings(15,15,25,25) ;

                args.Cell.Style = pdfGridCellStyle;

                //set value without tags

                string DisplayValue = Regex.Replace(input, "<.*?>", String.Empty);

                args.Cell.Value = DisplayValue;

            }

           

        }

    }


Kindly get back to us if you have any further queries


Regards,

Sarveswaran PK


Attachment: SfGridCellPadding_f64c560.zip

Loader.
Up arrow icon