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.

Mon Sep 16, 2013 10:21 pm

Hi

How can we create a PdfGrid with only the outside border i.e. no borders between between each cell?

Thanks
Fred

fso
 
Posts: 2
Joined: Wed Feb 16, 2011 5:20 pm

Tue Sep 17, 2013 8:09 am

Hi Fred,

Thanks for your inquiry.
Please refer to the following method in the attachment to create a PdfGrid with only the outside border.
If there are any questions, welcome to get it back to us.
Sincerely,
Gary
E-iceblue support team
User avatar

Gary.zhang
 
Posts: 1380
Joined: Thu Apr 04, 2013 1:30 am

Wed Sep 25, 2013 9:41 am

Hi Fred,

Have you tried the sample? Does it fulfill your need? Could you please give us some feedback if convenience?

If there are any questions, welcome to get it back to us.

Thanks And Regards,
Gary
E-iceblue support team
User avatar

Gary.zhang
 
Posts: 1380
Joined: Thu Apr 04, 2013 1:30 am

Wed Oct 02, 2013 2:55 am

Hello Fred,
Has the issue been resolved? Could you please give us some feedback at your early convenience ?
If you have any questions, welcome to give it back to us.

Regards.
Benjamin
E-iceblue support team
User avatar

Benjamin Du
 
Posts: 82
Joined: Thu Jul 25, 2013 2:38 am

Mon Mar 27, 2017 4:33 pm

This is exactly what I need, this will save me hours! However, the right boarders are not getting styled (they're blank). I can see every conditions statement firing off one time as expected.

bgates
 
Posts: 3
Joined: Mon Mar 27, 2017 3:36 pm

Tue Mar 28, 2017 2:02 am

Dear bgates,

Thanks for your inquiry.
If you are using older version of Spire.PDF, we first suggest upgrading to the latest Spire.PDF Pack(Hot Fix) Version:3.8.193. After trying this version, if the problem still persists, please offer us the code you were using for testing.

Thanks,
Betsy
E-iceblue support team
User avatar

Betsy.jiang
 
Posts: 3099
Joined: Tue Sep 06, 2016 8:30 am

Tue Mar 28, 2017 6:37 pm

PdfGrid DemographicGrid = new PdfGrid();
DemographicGrid.Columns.Add(5);
PdfGridRow DemographicGridRow1 = DemographicGrid.Rows.Add();
PdfGridRow DemographicGridRow2 = DemographicGrid.Rows.Add();
width = page2.Canvas.ClientSize.Width - (DemographicGrid.Columns.Count + 1);
DemographicGrid.Columns[0].Width = width * 0.25f;
DemographicGrid.Columns[1].Width = width * 0.30f;
DemographicGrid.Columns[4].Width = width * 0.25f;
DemographicGrid.Style.CellPadding = new PdfPaddings(1, 1, 1, 1);

textAndStyle.Text = "Demographic Information";
DemographicGridRow1.Style.BackgroundBrush = PdfBrushes.LightBlue;
DemographicGridRow1.Cells[0].Value = textAndStyle.Text;
DemographicGridRow1.Cells[0].StringFormat = new PdfStringFormat(PdfTextAlignment.Left, PdfVerticalAlignment.Middle);
DemographicGridRow1.Cells[0].ColumnSpan = 5;

DemographicGridRow2.Cells[0].Value = fullNameAddress;
DemographicGridRow2.Cells[0].StringFormat = new PdfStringFormat(PdfTextAlignment.Left, PdfVerticalAlignment.Middle);
DemographicGridRow2.Cells[0].ColumnSpan = 3;

DemographicGridRow2.Cells[3].Value = "Phone: " + dd.Phone;
DemographicGridRow2.Cells[3].StringFormat = new PdfStringFormat(PdfTextAlignment.Left, PdfVerticalAlignment.Middle);
DemographicGridRow2.Cells[3].ColumnSpan = 2;

y += (DemographicGrid.Rows.Count * 0.66f);

// Paint Grids White = paintGrid(DemographicGrid);
OuterBoardersOnly(DemographicGrid, page2, y);
// Draw Grids
DemographicGrid.Draw(page2, new PointF(0, y));

////////////////////////////////////////////////////////////////////////////////////////////

// ONLY SHOW OUTER BOARDER OF GRID
public void OuterBoardersOnly(PdfGrid grid, PdfPageBase page, float y)
{
PdfBrush brush = new PdfSolidBrush(Color.Black);
PdfPen pen = new PdfPen(brush, 1);
for (int i = 0; i < grid.Rows.Count; i++)
{
for (int j = 0; j < grid.Rows[i].Cells.Count; j++)
{
//grid.Rows[i].Cells[j].Value = "test";
grid.Rows[i].Cells[j].Style.Borders.All = new PdfPen(new PdfTilingBrush(new SizeF(0.1f, 0.1f)));
if (i == 0)
{
grid.Rows[i].Cells[j].Style.Borders.Top = pen;
if (j == 0)
{
grid.Rows[i].Cells[j].Style.Borders.Left = pen;
}
else if (j == grid.Rows[i].Cells.Count - 1)
{
grid.Rows[i].Cells[j].Style.Borders.Right = pen;
}
}
else if (i == grid.Rows.Count - 1)
{
grid.Rows[i].Cells[j].Style.Borders.Bottom = pen;
if (j == 0)
{
grid.Rows[i].Cells[j].Style.Borders.Left = pen;
}
else if (j == grid.Rows[i].Cells.Count - 1)
{
grid.Rows[i].Cells[j].Style.Borders.Right = pen;
}
}
else if (j == 0)
{
grid.Rows[i].Cells[j].Style.Borders.Left = pen;
}
else if (j == grid.Rows[i].Cells.Count - 1)
{
grid.Rows[i].Cells[j].Style.Borders.Right = pen;
}
}
}
//grid.Draw(page, new PointF(0, y));
}

bgates
 
Posts: 3
Joined: Mon Mar 27, 2017 3:36 pm

Wed Mar 29, 2017 4:09 am

Dear bgates,

Thanks for your inquiry.
I checked the code you provided, and found you set ColumnSpan on the cells below.
Code: Select all
DemographicGridRow1.Cells[0].ColumnSpan = 5;
DemographicGridRow2.Cells[3].ColumnSpan = 2;

Please reset the right border as below.
Code: Select all
            grid.Rows[0].Cells[0].Style.Borders.Right = pen;
            grid.Rows[1].Cells[3].Style.Borders.Right = pen;

If there is any question, please let me know.

Sincerely,
Betsy
E-iceblue support team
User avatar

Betsy.jiang
 
Posts: 3099
Joined: Tue Sep 06, 2016 8:30 am

Wed Mar 29, 2017 12:11 pm

Perceptive observation, thank you!

bgates
 
Posts: 3
Joined: Mon Mar 27, 2017 3:36 pm

Thu Mar 30, 2017 1:28 am

Dear bgates,

Thanks for your feedback.
Please feel free to contact us if you have any issue, we are here for help :) .

Sincerely,
Betsy
E-iceblue support team
User avatar

Betsy.jiang
 
Posts: 3099
Joined: Tue Sep 06, 2016 8:30 am

Return to Spire.PDF