We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
close icon

HTML styled text in pdf grid cell

in example below

private void Form1_Load(object sender, EventArgs e)
        {
            //create a new pdf document
            PdfDocument doc = new PdfDocument();

            //create new page
            PdfPage page = doc.Pages.Add();

            Font ffont = new Font("Arial", 6, FontStyle.Regular);

            //create a new pdf font
            PdfFont font = new PdfTrueTypeFont(ffont,true);

            //create a pdfgrid
            PdfGrid grid = new PdfGrid();

            //add new row to grid
            grid.Rows.Add();

            //add new column to grid
            grid.Columns.Add(10);

            PdfGridCellStyle style = new PdfGridCellStyle();
            style.Font = font;
            grid.Rows[0].Cells[0].Style = style;

            

            //measure the string height
            SizeF size = font.MeasureString("Toto jeřetězec, který sycnfusion státy by změna velikosti");

        
            grid.Rows[0].Height = size.Height + 1;
           
            
            //set the text to grid cell
            grid.Rows[0].Cells[0].Value = "Toto jeřetězec, který sycnfusion státy by změna velikosti";

            //draw the grid to pdf
            grid.Draw(page, PointF.Empty);

            //save the pdf document
            doc.Save("Pdfgrid.pdf");

            //close the document
            doc.Close(true);
            
        }


i want to display text as such

Toto jeřetězec, který sycnfusion státy by změna velikosti"

How can i acheive this?

1 Reply

AS Abirami Selvan Syncfusion Team May 29, 2015 10:20 AM UTC

Hi Jb,

Thanks for using syncfusion product.

Currently , We don’t have the support to draw the string with different styles in grid cell. So we have created the workaround sample using light table and pdf html element in grid.

We have attached the sample in below link:
http://www.syncfusion.com/downloads/support/forum/119251/ze/PdfGridSample-1476182792

Please try this and let us know if you need any further assistance.

Regards,
Abirami.

Loader.
Live Chat Icon For mobile
Up arrow icon