Spire.PDF is a professional PDF library applied to creating, writing, editing, handling and reading PDF files without any external dependencies. Get free and professional technical support for Spire.PDF for .NET, Java, Android, C++, Python.

Tue Apr 21, 2020 8:44 am

Hi

Please help me to draw or place the dashed border to grid cell.

I need this style -----------------------. But i got __________________

row.Cells[i].Style.Borders.Bottom = new PdfPen(Color.Black, 0.2f);

ushanandhini_1297
 
Posts: 16
Joined: Mon Apr 20, 2015 11:34 am

Tue Apr 21, 2020 9:37 am

Hello,

Thanks for your inquiry.
Sorry to tell that our Spire.PDF doesn't support this feature at present. However, we are considering adding it as a new feature to our further upgrade list with the ticket SPIREPDF-3196. If it can be achieved in the future, we will let you know.
Sorry for the inconvenience caused.

Sincerely,
Rachel
E-iceblue support team
User avatar

rachel.lei
 
Posts: 1571
Joined: Tue Jul 09, 2019 2:22 am

Wed Dec 30, 2020 6:22 am

Hello,

Hope you are doing well.
Please refer to the following code to draw dashed border for grid cell. Any questions, just feel free to contact us.
Code: Select all
            PdfDocument pdf = new PdfDocument();
            PdfPageBase page = pdf.Pages.Add();
            float penWidth = 1;
            PdfBrush brush = PdfBrushes.Red;
            //Create a pen
            PdfPen pen = new PdfPen(brush, penWidth);
            //Set the dash style
            pen.DashStyle = PdfDashStyle.Custom;
            pen.DashPattern = new float[] { 2, 1 };

            PdfBorders border = new PdfBorders();
            border.All = pen;

            PdfGridCellStyle cellStyle = new PdfGridCellStyle();
            cellStyle.Borders = border;

            PdfGrid grid = new PdfGrid();
            grid.Columns.Add(2);
            foreach (PdfGridColumn column in grid.Columns)
            {
                column.Width = 150;
            }
            grid.Rows.Add();
            foreach (PdfGridRow row in grid.Rows)
            {
                row.Height = 30;
                foreach (PdfGridCell cell in row.Cells)
                {
                    cell.Style = cellStyle;
                }
            }
            grid.Draw(page, 10, 10);
            pdf.SaveToFile("result.pdf", FileFormat.PDF);


Sincerely,
Rachel
E-iceblue support team
User avatar

rachel.lei
 
Posts: 1571
Joined: Tue Jul 09, 2019 2:22 am

Return to Spire.PDF