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.

Thu Apr 29, 2021 6:14 am

si.png


I struggling to make above structure in pdf but not able to,please help.

kuntal.bose
 
Posts: 20
Joined: Thu Apr 29, 2021 6:05 am

Thu Apr 29, 2021 11:50 am

Hello,

Thanks for your inquiry.
If you want to create a new grid and remove the bottom border, you can refer to the following code to meet your requirements.
Code: Select all
            PdfDocument doc = new PdfDocument();
            PdfPageBase page = doc.Pages.Add();
            PdfGrid grid = new PdfGrid();
            grid.Columns.Add(5);
            grid.Rows.Add().Height=25;

            foreach (PdfGridRow row in grid.Rows)
            {
                foreach (PdfGridCell cell in row.Cells)
                {
                    cell.Style.Borders.All = new PdfPen(Color.Black);
                    cell.Style.Borders.Bottom = new PdfPen(Color.Transparent);
                    cell.StringFormat = new PdfStringFormat(PdfTextAlignment.Justify, PdfVerticalAlignment.Middle);
                }
            }

            PdfLayoutResult result = grid.Draw(page, new PointF(0, 10));
            doc.SaveToFile("result.pdf");


But if you want to load an existing PDF and then remove the bottom border of the grid, sorry, our Spire.PDF cannot achieve that.

If you have any other questions, please feel free to contact us.

Sincerely,
Brian
E-iceblue support team
User avatar

Brian.Li
 
Posts: 1271
Joined: Mon Oct 19, 2020 3:04 am

Fri Apr 30, 2021 3:57 am

Hi Brain
Thanks for reply,But I face some issue . I add multiple rows ,

Code: Select all
PdfDocument doc = new PdfDocument();
            PdfPageBase page = doc.Pages.Add();
            PdfGrid grid = new PdfGrid();
           
            grid.Columns.Add(5);

            grid.Rows.Add().Height = 25;
            grid.Rows.Add().Height = 25;
            grid.Rows.Add().Height = 25;
            grid.Rows.Add().Height = 25;
            grid.Rows.Add().Height = 25;
            grid.Rows.Add().Height = 25;

            foreach (PdfGridRow row in grid.Rows)
            {
                foreach (PdfGridCell cell in row.Cells)
                {
                    cell.Style.Borders.All = new PdfPen(System.Drawing.Color.Black);
                    cell.Style.Borders.Bottom = new PdfPen(System.Drawing.Color.Transparent);
                    cell.StringFormat = new PdfStringFormat(PdfTextAlignment.Justify, PdfVerticalAlignment.Middle);
                }
            }
            PdfLayoutResult result = grid.Draw(page, new PointF(0, 10));
            doc.SaveToFile("result.pdf");

and then output is not expected .
row.png

I am expecting an output like bellow image
row1.png

kuntal.bose
 
Posts: 20
Joined: Thu Apr 29, 2021 6:05 am

Fri Apr 30, 2021 6:43 am

Hello,

Thanks for your feedback.
Please refer to the following code to meet your needs. If you have any other questions, please feel free to contact us.
Code: Select all
            PdfDocument doc = new PdfDocument();
            PdfPageBase page = doc.Pages.Add();
            PdfGrid grid = new PdfGrid();

            grid.Columns.Add(5);

            grid.Rows.Add().Height = 25;
            grid.Rows.Add().Height = 25;
            grid.Rows.Add().Height = 25;
            grid.Rows.Add().Height = 25;
            grid.Rows.Add().Height = 25;
            grid.Rows.Add().Height = 25;

            for (int i=0; i<grid.Rows.Count;i++)
            {
                if (i==1 || i==2 || i== 3 || i == 4)
                {
                    foreach (PdfGridCell cell in grid.Rows[i].Cells)
                    {
                        cell.Style.Borders.Top = new PdfPen(System.Drawing.Color.Transparent);
                        cell.Style.Borders.Bottom = new PdfPen(System.Drawing.Color.Transparent);
                    }
                }
                else
                {
                    foreach (PdfGridCell cell in grid.Rows[i].Cells)
                    {
                        cell.Style.Borders.All = new PdfPen(System.Drawing.Color.Black);
                    }
                }
            }
            PdfLayoutResult result = grid.Draw(page, new PointF(0, 10));
            doc.SaveToFile("result.pdf");



Sincerely,
Brian
E-iceblue support team
User avatar

Brian.Li
 
Posts: 1271
Joined: Mon Oct 19, 2020 3:04 am

Fri Apr 30, 2021 7:33 am

Thanks Working Fine

kuntal.bose
 
Posts: 20
Joined: Thu Apr 29, 2021 6:05 am

Fri Apr 30, 2021 7:48 am

You are welcome.
If you encounter any issues related to our products in the future, please feel free to contact us.

Sincerely,
Brian
E-iceblue support team
User avatar

Brian.Li
 
Posts: 1271
Joined: Mon Oct 19, 2020 3:04 am

Return to Spire.PDF