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.

Fri Dec 02, 2022 5:32 am

Hi,
I want to reduce the border width of the grid present on the following image.
I used PDF grid to generate this.
Please let me know how to achieve that.

suryaks2002
 
Posts: 17
Joined: Wed Nov 09, 2022 7:57 am

Fri Dec 02, 2022 10:00 am

Hello,

Thanks for your inquiry.
For your inquiry, please refer to the following code.
Code: Select all
//Create the PDF document
            PdfDocument doc = new PdfDocument();
            //Add the first page
            PdfPageBase page = doc.Pages.Add();
            //Create grid
            PdfGrid grid = new PdfGrid();
            //Add a row
            PdfGridRow row1 = grid.Rows.Add();
            grid.Columns.Add(2);


            //Set border size and color of cell1 to 1f and black.
            PdfPen pdfpen1 = new PdfPen(Color.Black, 1f);
            row1.Cells[0].Style.Borders.All = pdfpen1;

            //Set border size and color of cell1 to 2f and red.
            PdfPen pdfpen2 = new PdfPen(Color.Red, 2f);
            row1.Cells[1].Style.Borders.All = pdfpen2;


            //Fill data
            string str = "Hello Word!";
            for (int i = 0; i < grid.Columns.Count; i++)
            {
                row1.Cells[i].Value = str;
            }

            //Draw the grid on page
            grid.Draw(page, new PointF(0, 50));

            //Save pdf file
            string result = @"../../output/PDFNoneBorderGrid.pdf";
            doc.SaveToFile(result, FileFormat.PDF);

In addition, for the grid table, there is no support for merging cells in the grid that has already been generated, but you can merge cells during the process of adding a grid table. You can refer to the help document from the following link.
https://www.e-iceblue.com/Tutorials/Spi ... e.PDF.html

Sincerely
Abel
E-iceblue support team
User avatar

Abel.He
 
Posts: 1010
Joined: Tue Mar 08, 2022 2:02 am

Return to Spire.PDF