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 Mar 14, 2024 12:36 pm

I am using FreeSpire.pdf demo version and trying to generate pdf document using PdfGrid and PdfGridRow with dynamic data.
But at end of every page, border is not consistent sometimes border is coming sometimes not.
Pdf generated file attached.
Vesrion - FreeSpire.pdf(8.6.0)
Environment - Windows 10 (64 bit) United State
Application - MS .Net Core API (3.1)

Code:
private async Task<byte[]> GeneratePdfFromHtml(int assessmentId, AssessmentViewModel assessmentViewModel = null, int colleagueAssessmentId = 0, bool isHideScore = true, bool isColleagueLevel = false, int userId = 0, int consultationId = 0, int colleagueId = 0, int meetingId = 0)
{
PdfDocument.EnableFontCache = false;
string rootPath = System.IO.Directory.GetCurrentDirectory();
var templatePath = Path.Combine(rootPath, "Template\\Blank.pdf");

PdfDocument pdf = new PdfDocument();
PdfDocument.EnableFontCache = false;

// Margins
PdfUnitConvertor unitCvtr = new PdfUnitConvertor();
PdfMargins margin = new PdfMargins();
//margin.Top = unitCvtr.ConvertUnits(2.54f, PdfGraphicsUnit.Centimeter, PdfGraphicsUnit.Point);
//margin.Bottom = margin.Top;
//margin.Left = unitCvtr.ConvertUnits(3.17f, PdfGraphicsUnit.Centimeter, PdfGraphicsUnit.Point);
//margin.Right = margin.Left;

margin.Top = 30;
margin.Bottom = 30;
margin.Left = 14;
margin.Right = 0;

PdfDocument.EnableFontCache = false;

pdf.AllowCreateForm = (pdf.Form == null) ? true : false;
//PdfPageBase page = pdf.Pages.Add(PdfPageSize.A4, margin);
PdfPageBase page = pdf.Pages.Add(PdfPageSize.A4, margin, PdfPageRotateAngle.RotateAngle0, PdfPageOrientation.Portrait);
PdfPageBase newPage;

bool? isNewPage = false;
bool? isNewPageAdded = false;
int newPageIndex = 0;

PdfFont font = new PdfFont(PdfFontFamily.Helvetica, 13f);
PdfBrush brush = PdfBrushes.Black;
PdfStringFormat format = new PdfStringFormat();
format.LineSpacing = font.Size * 1.5f;

//float x = 70;
//float y = 140;
//float xRect = 475;
// float yRect = 15;
float y = 10;
float x1 = page.Canvas.ClientSize.Width;


//page.Canvas.DrawString("PRIVATE & CONFIDENTIAL", new PdfFont(PdfFontFamily.Helvetica, 10f, PdfFontStyle.Bold), brush, x, 50);
//var imagePath = Path.Combine(rootPath, "Template\\CSTLogo.png");
//PdfImage image = PdfImage.FromFile(imagePath);
//page.Canvas.DrawImage(image, 220, 65, 300, 23);


PdfGrid grid = new PdfGrid();
grid.BeginPageLayout += new BeginPageLayoutEventHandler(grid_BeginPageLayout);
PdfGridLayoutFormat gridLayout = new PdfGridLayoutFormat();
gridLayout.Break = PdfLayoutBreakType.FitElement;
gridLayout.Layout = PdfLayoutType.Paginate;

PdfGridStyle gridStyle = new PdfGridStyle();

PdfBorders borderAll = new PdfBorders();
borderAll.All = new PdfPen(Color.Black, 0.5f);

grid.Style.CellPadding = new PdfPaddings(6, 0, 0, 0);

//grid.Columns.Add(3);
//float width = page.Canvas.ClientSize.Width - (grid.Columns.Count + 1);
//grid.Columns[0].Width = width * 0.35f;
//grid.Columns[1].Width = width * 0.45f;
grid.Columns.Add(3);
float width = page.Canvas.ClientSize.Width - (grid.Columns.Count + 1);
grid.Columns[0].Width = width * 0.25f;
grid.Columns[1].Width = width * 0.55f;
grid.Columns[2].Width = width * 0.18f;

// set rows
PdfGridRow row0 = grid.Rows.Add();
PdfGridRow row1 = grid.Rows.Add();
PdfGridRow row2 = grid.Rows.Add();
PdfGridRow row3 = grid.Rows.Add();
PdfGridRow row4 = grid.Rows.Add();
PdfGridRow row5 = grid.Rows.Add();
PdfGridRow row6 = grid.Rows.Add();
PdfGridRow row7 = grid.Rows.Add();
PdfGridRow row8 = grid.Rows.Add();
PdfGridRow row9 = grid.Rows.Add();
PdfGridRow row10 = grid.Rows.Add();
PdfGridRow row11 = grid.Rows.Add();
PdfGridRow row12 = grid.Rows.Add();
PdfGridRow row13 = grid.Rows.Add();
PdfGridRow row14 = grid.Rows.Add();
PdfGridRow row15 = grid.Rows.Add();
PdfGridRow row16 = grid.Rows.Add();
PdfGridRow row17 = grid.Rows.Add();
float height = 20.0f;
for (int i = 0; i < grid.Rows.Count; i++)
{
grid.Rows[i].Height = height;
}


row0.Style.Font = new PdfTrueTypeFont(new Font("Arial", 16f, FontStyle.Bold), true);
row1.Style.Font = new PdfTrueTypeFont(new Font("Arial", 16f, FontStyle.Italic), true);

string heading = "Colleague Assessment Form";
string headingGuidanceNote = "Guidance Notes for completion of the Colleague Assessment Form (CAF)";
PdfBrush headingTextBrush = PdfBrushes.White;
PdfBrush headingBackgroundBrush = PdfBrushes.Red;

PdfRGBColor redColor = new PdfRGBColor(192, 0, 0);
PdfSolidBrush redColorBrush = new PdfSolidBrush(redColor);

row0.Cells[0].Value = heading;
row0.Cells[0].Style.Font = new PdfTrueTypeFont(new Font("Mary Ann", 11f, FontStyle.Bold | FontStyle.Bold), true);
row0.Cells[0].Style.TextBrush = headingTextBrush;
row0.Cells[0].StringFormat = new PdfStringFormat(PdfTextAlignment.Center, PdfVerticalAlignment.Middle);
row0.Cells[0].Style.BackgroundBrush = headingBackgroundBrush;
row0.Cells[0].ColumnSpan = 3;

row1.Cells[0].Value = "Colleague name:";
row1.Cells[0].Style.Font = new PdfTrueTypeFont(new Font("Mary Ann", 10f, FontStyle.Bold | FontStyle.Regular), true);
row1.Cells[0].StringFormat = new PdfStringFormat(PdfTextAlignment.Left, PdfVerticalAlignment.Middle);
row1.Cells[1].Value = colleagueName;
row1.Cells[1].Style.Font = new PdfTrueTypeFont(new Font("Mary Ann", 10f, FontStyle.Bold | FontStyle.Regular), true);
row1.Cells[1].StringFormat = new PdfStringFormat(PdfTextAlignment.Left, PdfVerticalAlignment.Middle);
row1.Cells[1].ColumnSpan = 2;

row2.Cells[0].Value = "Consultation manager:";
row2.Cells[0].Style.Font = new PdfTrueTypeFont(new Font("Mary Ann", 10f, FontStyle.Bold | FontStyle.Regular), true);
row2.Cells[0].StringFormat = new PdfStringFormat(PdfTextAlignment.Left, PdfVerticalAlignment.Middle);
row2.Cells[1].Value = consultationManager;
row2.Cells[1].Style.Font = new PdfTrueTypeFont(new Font("Mary Ann", 10f, FontStyle.Bold | FontStyle.Regular), true);
row2.Cells[1].StringFormat = new PdfStringFormat(PdfTextAlignment.Left, PdfVerticalAlignment.Middle);
row2.Cells[1].ColumnSpan = 2;

row3.Cells[0].Value = "Colleague grade:";
row3.Cells[0].Style.Font = new PdfTrueTypeFont(new Font("Mary Ann", 10f, FontStyle.Bold | FontStyle.Regular), true);
row3.Cells[0].StringFormat = new PdfStringFormat(PdfTextAlignment.Left, PdfVerticalAlignment.Middle);
row3.Cells[1].Value = colleagueGrade;
row3.Cells[1].Style.Font = new PdfTrueTypeFont(new Font("Mary Ann", 10f, FontStyle.Bold | FontStyle.Regular), true);
row3.Cells[1].StringFormat = new PdfStringFormat(PdfTextAlignment.Left, PdfVerticalAlignment.Middle);
row3.Cells[1].ColumnSpan = 2;

row4.Cells[0].Value = "Date completed:";
row4.Cells[0].Style.Font = new PdfTrueTypeFont(new Font("Mary Ann", 10f, FontStyle.Bold | FontStyle.Regular), true);
row4.Cells[0].StringFormat = new PdfStringFormat(PdfTextAlignment.Left, PdfVerticalAlignment.Middle);
row4.Cells[1].Value = dateCompleted;
row4.Cells[1].Style.Font = new PdfTrueTypeFont(new Font("Mary Ann", 10f, FontStyle.Bold | FontStyle.Regular), true);
row4.Cells[1].StringFormat = new PdfStringFormat(PdfTextAlignment.Left, PdfVerticalAlignment.Middle);
row4.Cells[1].ColumnSpan = 2;

row5.Cells[0].Value = "Colleague job title:";
row5.Cells[0].Style.Font = new PdfTrueTypeFont(new Font("Mary Ann", 10f, FontStyle.Bold | FontStyle.Regular), true);
row5.Cells[0].StringFormat = new PdfStringFormat(PdfTextAlignment.Left, PdfVerticalAlignment.Middle);
row5.Cells[1].Value = colleagueJobTitle;
row5.Cells[1].Style.Font = new PdfTrueTypeFont(new Font("Mary Ann", 10f, FontStyle.Bold | FontStyle.Regular), true);
row5.Cells[1].StringFormat = new PdfStringFormat(PdfTextAlignment.Left, PdfVerticalAlignment.Middle);
row5.Cells[1].ColumnSpan = 2;

row6.Cells[0].Value = "Role being assessed against:";
row6.Cells[0].Style.Font = new PdfTrueTypeFont(new Font("Mary Ann", 10f, FontStyle.Bold | FontStyle.Regular), true);
row6.Cells[0].StringFormat = new PdfStringFormat(PdfTextAlignment.Left, PdfVerticalAlignment.Middle);
row6.Cells[1].Value = roleBeingAssessed;
row6.Cells[1].Style.Font = new PdfTrueTypeFont(new Font("Mary Ann", 10f, FontStyle.Bold | FontStyle.Regular), true);
row6.Cells[1].StringFormat = new PdfStringFormat(PdfTextAlignment.Left, PdfVerticalAlignment.Middle);
row6.Cells[1].ColumnSpan = 2;

row7.Cells[0].Value = headingGuidanceNote;
row7.Cells[0].Style.Font = new PdfTrueTypeFont(new Font("Mary Ann", 11f, FontStyle.Bold | FontStyle.Bold), true);
row7.Cells[0].Style.TextBrush = headingTextBrush;
row7.Cells[0].StringFormat = new PdfStringFormat(PdfTextAlignment.Center, PdfVerticalAlignment.Middle);
row7.Cells[0].Style.BackgroundBrush = headingBackgroundBrush;
row7.Cells[0].ColumnSpan = 3;

row8.Cells[0].Value = "Section 1 - Match with Role";
row8.Cells[0].Style.Font = new PdfTrueTypeFont(new Font("Mary Ann", 11f, FontStyle.Bold | FontStyle.Bold), true);
row8.Cells[0].StringFormat = new PdfStringFormat(PdfTextAlignment.Center, PdfVerticalAlignment.Middle);
row8.Cells[0].Style.BackgroundBrush = PdfBrushes.LightGray;
row8.Cells[0].ColumnSpan = 3;


PdfBorders borderBotttom = new PdfBorders();
borderBotttom.Bottom = new PdfPen(Color.White);
borderBotttom.Top = new PdfPen(Color.White);


grid.Rows[9].Height = 30.0f;
row9.Cells[0].Value = "Colleagues should be informed during their first individual consultation meeting of the 3 ’Technical Knowledge' and 3 'Value/Behaviours' areas of the role profile that will be used as assessment criteria";
row9.Cells[0].StringFormat = new PdfStringFormat(PdfTextAlignment.Left, PdfVerticalAlignment.Middle);
row9.Style.Font = new PdfTrueTypeFont(new Font("Arial", 10f, FontStyle.Regular | FontStyle.Regular), true);
row9.Cells[0].ColumnSpan = 3;
row9.Cells[0].Style.Borders = borderBotttom;


if (assessmentType == AssessmentType.CAF)
{
grid.Rows[10].Height = 80.0f;
row10.Cells[0].Value = "Colleagues should be provided with a blank copy of an assessment form with the criteria, should the colleague wish to prepare a self-assessment. If a colleague does wish to complete a self-assessment, they should bring this to their second consultation meeting. During this meeting, the line manager should acknowledge the colleague’s evidence and consider this as part of the assessment. The line manager owns the wording on the CAF form, therefore has final say on the evidence that will be included in the last version. The review period for the assessment should be 12 months.";
row10.Cells[0].StringFormat = new PdfStringFormat(PdfTextAlignment.Left, PdfVerticalAlignment.Middle);
row10.Style.Font = new PdfTrueTypeFont(new Font("Arial", 10f, FontStyle.Regular | FontStyle.Regular), true);
row10.Cells[0].ColumnSpan = 3;
row10.Cells[0].Style.Borders = borderBotttom;
}
if (assessmentType == AssessmentType.DAF)
{
grid.Rows[10].Height = 15.0f;
row10.Cells[0].Value = "The review period for the assessment should be 12 months.";
row10.Cells[0].StringFormat = new PdfStringFormat(PdfTextAlignment.Left, PdfVerticalAlignment.Middle);
row10.Style.Font = new PdfTrueTypeFont(new Font("Arial", 10f, FontStyle.Regular | FontStyle.Regular), true);
row10.Cells[0].ColumnSpan = 3;
row10.Cells[0].Style.Borders = borderBotttom;
}


grid.Rows[11].Height = 30.0f;
row11.Cells[0].Value = "The line manager completing this form should score the colleague for each Technical Knowledge and Value/Behaviour criteria, as follows:";
row11.Cells[0].StringFormat = new PdfStringFormat(PdfTextAlignment.Left, PdfVerticalAlignment.Middle);
row11.Style.Font = new PdfTrueTypeFont(new Font("Arial", 10f, FontStyle.Regular | FontStyle.Regular), true);
row11.Cells[0].ColumnSpan = 3;
row11.Cells[0].Style.Borders = borderBotttom;


//-------------Create another grid to embed
PdfGrid embedGrid = new PdfGrid();
embedGrid.Style.CellPadding = new PdfPaddings(6, 0, 0, 0);
PdfGridRow newRow0 = embedGrid.Rows.Add();
PdfGridRow newRow1 = embedGrid.Rows.Add();
PdfGridRow newRow2 = embedGrid.Rows.Add();
PdfGridRow newRow3 = embedGrid.Rows.Add();
PdfGridRow newRow4 = embedGrid.Rows.Add();
PdfGridRow newRow5 = embedGrid.Rows.Add();
embedGrid.Columns.Add(2);
embedGrid.Columns[0].Width = 70f;
embedGrid.Columns[1].Width = 470f;

newRow0.Cells[0].Value = "Score";
newRow0.Cells[0].StringFormat = new PdfStringFormat(PdfTextAlignment.Center, PdfVerticalAlignment.Middle);
newRow0.Cells[0].Style.BackgroundBrush = PdfBrushes.LightGray;
newRow0.Cells[1].Value = "Description";
newRow0.Cells[1].StringFormat = new PdfStringFormat(PdfTextAlignment.Center, PdfVerticalAlignment.Middle);
newRow0.Cells[1].Style.BackgroundBrush = PdfBrushes.LightGray;
newRow0.Style.Font = new PdfTrueTypeFont(new Font("Arial", 10f, FontStyle.Bold | FontStyle.Regular), true);


newRow1.Cells[0].Value = "0";
newRow1.Cells[0].StringFormat = new PdfStringFormat(PdfTextAlignment.Center, PdfVerticalAlignment.Middle);
newRow1.Cells[1].Value = "Colleague does not meet the expectations of the criteria, with no or negative evidence ";
newRow1.Cells[1].StringFormat = new PdfStringFormat(PdfTextAlignment.Left, PdfVerticalAlignment.Middle);
newRow1.Style.Font = new PdfTrueTypeFont(new Font("Arial", 10f, FontStyle.Regular | FontStyle.Regular), true);

newRow2.Cells[0].Value = "1";
newRow2.Cells[0].StringFormat = new PdfStringFormat(PdfTextAlignment.Center, PdfVerticalAlignment.Middle);
newRow2.Cells[1].Value = "Colleague meets some of the expectations of the criteria, with some positive evidence but the majority are negative or opportunities ";
newRow2.Cells[1].StringFormat = new PdfStringFormat(PdfTextAlignment.Left, PdfVerticalAlignment.Middle);
newRow2.Style.Font = new PdfTrueTypeFont(new Font("Arial", 10f, FontStyle.Regular | FontStyle.Regular), true);

newRow3.Cells[0].Value = "2";
newRow3.Cells[0].StringFormat = new PdfStringFormat(PdfTextAlignment.Center, PdfVerticalAlignment.Middle);
newRow3.Cells[1].Value = "Colleague meets most of the expectations of the criteria, with positive evidence and only minor opportunities";
newRow3.Cells[1].StringFormat = new PdfStringFormat(PdfTextAlignment.Left, PdfVerticalAlignment.Middle);
newRow3.Style.Font = new PdfTrueTypeFont(new Font("Arial", 10f, FontStyle.Regular | FontStyle.Regular), true);

newRow4.Cells[0].Value = "3";
newRow4.Cells[0].StringFormat = new PdfStringFormat(PdfTextAlignment.Center, PdfVerticalAlignment.Middle);
newRow4.Cells[1].Value = "Colleague meets all the expectations of the criteria, with all positive evidence ";
newRow4.Cells[1].StringFormat = new PdfStringFormat(PdfTextAlignment.Left, PdfVerticalAlignment.Middle);
newRow4.Style.Font = new PdfTrueTypeFont(new Font("Arial", 10f, FontStyle.Regular | FontStyle.Regular), true);

newRow5.Cells[0].Value = "4";
newRow5.Cells[0].StringFormat = new PdfStringFormat(PdfTextAlignment.Center, PdfVerticalAlignment.Middle);
newRow5.Cells[1].Value = "Colleague exceeds all the expectations of the criteria, with all incredibly positive and consistent evidence ";
newRow5.Cells[1].StringFormat = new PdfStringFormat(PdfTextAlignment.Left, PdfVerticalAlignment.Middle);
newRow5.Style.Font = new PdfTrueTypeFont(new Font("Arial", 10f, FontStyle.Regular | FontStyle.Regular), true);

grid.Rows[12].Height = 125.0f;
row12.Cells[0].Value = embedGrid;
row12.Cells[0].ColumnSpan = 3;
row12.Style.CellPadding = new PdfPaddings(6, 6, 6, 6);
row12.Cells[0].Style.Borders = borderBotttom;
//-------------Create another grid to embed

grid.Rows[13].Height = 30.0f;
row13.Cells[0].Value = "The maximum total a colleague can score for this form is 24 points e.g. 3 areas of up to 4 points for Technical Knowledge (3x4) and 3 areas of up to 4 points for Value/Behaviours (3x4)";
row13.Cells[0].StringFormat = new PdfStringFormat(PdfTextAlignment.Left, PdfVerticalAlignment.Middle);
row13.Style.Font = new PdfTrueTypeFont(new Font("Arial", 10f, FontStyle.Regular | FontStyle.Regular), true);
row13.Cells[0].ColumnSpan = 3;
row13.Cells[0].Style.Borders = borderBotttom;

grid.Rows[14].Height = 30.0f;
row14.Cells[0].Value = "Line managers should use their own judgement and knowledge of the colleague to provide unambiguous evidence to support each Technical Knowledge and Value/Behaviour assessment criteria. ";
row14.Cells[0].StringFormat = new PdfStringFormat(PdfTextAlignment.Left, PdfVerticalAlignment.Middle);
row14.Style.Font = new PdfTrueTypeFont(new Font("Arial", 10f, FontStyle.Regular | FontStyle.Regular), true);
row14.Cells[0].ColumnSpan = 3;
row14.Cells[0].Style.Borders = borderBotttom;


if (assessmentType == AssessmentType.CAF)
{
grid.Rows[15].Height = 30.0f;
row15.Cells[0].Value = "Whist completing the form please consider the minimum performance standards alongside the role profile and requirements of the role. ";
row15.Cells[0].StringFormat = new PdfStringFormat(PdfTextAlignment.Left, PdfVerticalAlignment.Middle);
row15.Style.Font = new PdfTrueTypeFont(new Font("Arial", 10f, FontStyle.Regular | FontStyle.Regular), true);
row15.Cells[0].ColumnSpan = 3;
row15.Cells[0].Style.Borders = borderBotttom;
}
if (assessmentType == AssessmentType.DAF)
{
grid.Rows[15].Height = 0.0f;
row15.Cells[0].Value = "";
row15.Cells[0].StringFormat = new PdfStringFormat(PdfTextAlignment.Left, PdfVerticalAlignment.Middle);
row15.Style.Font = new PdfTrueTypeFont(new Font("Arial", 10f, FontStyle.Regular | FontStyle.Regular), true);
row15.Cells[0].ColumnSpan = 3;
row15.Cells[0].Style.Borders = borderAll;
}



grid.Rows[16].Height = 40.0f;
row16.Cells[0].Value = "The highest scoring colleague(s) will be offered the role. Where we are not able to differentiate between scores, an interview process may take place. ";
row16.Cells[0].StringFormat = new PdfStringFormat(PdfTextAlignment.Left, PdfVerticalAlignment.Middle);
row16.Style.Font = new PdfTrueTypeFont(new Font("Arial", 10f, FontStyle.Regular | FontStyle.Regular), true);
row16.Cells[0].ColumnSpan = 3;
row16.Cells[0].Style.Borders = borderBotttom;


row17.Cells[0].Value = "Does Not Meet = 0 points, Meets some = 1 points, Meets most = 2 points, Meets all = 3 points, Exceeds = 4 points ";
row17.Cells[0].StringFormat = new PdfStringFormat(PdfTextAlignment.Left, PdfVerticalAlignment.Middle);
row17.Style.Font = new PdfTrueTypeFont(new Font("Arial", 10f, FontStyle.Regular | FontStyle.Regular), true);
row17.Cells[0].ColumnSpan = 3;


//grid.Style.CellPadding = new PdfPaddings(6, 0, 0, 0);
PdfBorders borderBotttom1 = new PdfBorders();
borderBotttom1.Bottom = new PdfPen(Color.White);
PdfBorders borderTop1 = new PdfBorders();
borderTop1.Top = new PdfPen(Color.White);
PdfBorders borderRight1 = new PdfBorders();
borderRight1.Right = new PdfPen(Color.White);
PdfBorders borderLeft1 = new PdfBorders();
borderLeft1.Left = new PdfPen(Color.White);

PdfBorders borderTopBotttom1 = new PdfBorders();
borderTopBotttom1.Top = new PdfPen(Color.White);
borderTopBotttom1.Bottom = new PdfPen(Color.White);
PdfBorders borderLeftRight1 = new PdfBorders();
borderLeftRight1.Left = new PdfPen(Color.White);
borderLeftRight1.Right = new PdfPen(Color.White);


// set rows
PdfGridRow row18 = grid.Rows.Add();
PdfGridRow row19 = grid.Rows.Add();
PdfGridRow row20 = grid.Rows.Add();

//float height1 = 20.0f;
//for (int i = 0; i < grid.Rows.Count; i++)
//{
// grid.Rows[i].Height = height1;
//}

row18.Cells[0].Value = "Area";
row18.Cells[0].Style.Font = new PdfTrueTypeFont(new Font("Mary Ann", 10f, FontStyle.Bold | FontStyle.Regular), true);
row18.Cells[0].StringFormat = new PdfStringFormat(PdfTextAlignment.Center, PdfVerticalAlignment.Middle);
row18.Cells[0].Style.Borders = borderBotttom1;
row18.Cells[1].Value = "Evidence";
row18.Cells[1].Style.Font = new PdfTrueTypeFont(new Font("Mary Ann", 10f, FontStyle.Bold | FontStyle.Regular), true);
row18.Cells[1].StringFormat = new PdfStringFormat(PdfTextAlignment.Center, PdfVerticalAlignment.Middle);
row18.Cells[1].Style.Borders = borderBotttom1;
row18.Cells[2].Value = "Colleague’s Score";
row18.Cells[2].Style.Font = new PdfTrueTypeFont(new Font("Mary Ann", 10f, FontStyle.Bold | FontStyle.Regular), true);
row18.Cells[2].StringFormat = new PdfStringFormat(PdfTextAlignment.Center, PdfVerticalAlignment.Middle);
row18.Cells[2].RowSpan = 3;

row19.Cells[0].Value = "Technical Knowledge";
row19.Cells[0].Style.Font = new PdfTrueTypeFont(new Font("Mary Ann", 10f, FontStyle.Bold | FontStyle.Regular), true);
row19.Cells[0].StringFormat = new PdfStringFormat(PdfTextAlignment.Center, PdfVerticalAlignment.Middle);
row19.Cells[0].Style.Borders = borderTopBotttom1;
row19.Cells[1].Value = "3 evidence-based responses required for ‘Technical Knowledge’";
row19.Cells[1].Style.Font = new PdfTrueTypeFont(new Font("Arial", 8f, FontStyle.Regular | FontStyle.Regular), true);
row19.Cells[1].StringFormat = new PdfStringFormat(PdfTextAlignment.Center, PdfVerticalAlignment.Top);
row19.Cells[1].Style.Borders = borderTopBotttom1;

row20.Cells[0].Value = "(from role profile)";
row20.Cells[0].Style.Font = new PdfTrueTypeFont(new Font("Arial", 8f, FontStyle.Regular | FontStyle.Regular), true);
row20.Cells[0].StringFormat = new PdfStringFormat(PdfTextAlignment.Center, PdfVerticalAlignment.Top);
row20.Cells[0].Style.Borders = borderTop1;
row20.Cells[1].Value = "Line Manager Feedback";
row20.Cells[1].Style.Font = new PdfTrueTypeFont(new Font("Mary Ann", 10f, FontStyle.Regular | FontStyle.Regular), true);
row20.Cells[1].StringFormat = new PdfStringFormat(PdfTextAlignment.Center, PdfVerticalAlignment.Middle);

if (assessmentColleagueViewModel != null)
{
foreach (var item in assessmentColleagueViewModel.TechnicalAssessmentDetails)
{
//string hello50 = hello.PadRight(50);
//string title = item.title;
//string description = item.description;
//string titledescription = item.title + " " + item.description;

//if (string.IsNullOrEmpty(item.Description) || titleDescription.Length < 100)
//{
// row21.Height = 60.0f;
//}

StringBuilder titledescription = new StringBuilder();
titledescription.Append(item.Title);
titledescription.Append(System.Environment.NewLine);
titledescription.Append(item.Description);
float titledescriptionRowHeight = GetTitleRowHeight(titledescription.ToString());
float feedbackRowHeight = GetFeedbackRowHeight(item.Feedback);
float finalRowHeight = 0;
if (feedbackRowHeight > titledescriptionRowHeight)
{
finalRowHeight = feedbackRowHeight;
}
else
{
finalRowHeight = titledescriptionRowHeight;
}

PdfGridRow row21 = grid.Rows.Add();
row21.Height = finalRowHeight;
//PdfGridRow row212 = grid.Rows.Add();

row21.Cells[0].Value = titledescription.ToString();
row21.Cells[0].Style.Font = new PdfTrueTypeFont(new Font("Arial", 10f, FontStyle.Regular | FontStyle.Regular), true);
row21.Cells[0].StringFormat = new PdfStringFormat(PdfTextAlignment.Left, PdfVerticalAlignment.Top);
row21.Cells[0].Style.Borders = borderBotttom1;

//row212.Cells[0].Value = item.Description;
//row212.Height = descriptionRowHeight;
//row212.Cells[0].Style.Font = new PdfTrueTypeFont(new Font("Arial", 10f, FontStyle.Regular | FontStyle.Regular), true);
//row212.Cells[0].StringFormat = new PdfStringFormat(PdfTextAlignment.Left, PdfVerticalAlignment.Top);
//row212.Cells[0].Style.Borders = borderTop1;
//row212.Cells[1].Style.Borders = borderTop1;
//row212.Cells[2].Style.Borders = borderTop1;
//if (string.IsNullOrEmpty(item.Description) || item.Description.Length < 100)
//{
// row212.Height = 60.0f;
//}

row21.Cells[1].Value = item.Feedback;
//row21.Height = feedbackRowHeight;
row21.Cells[1].Style.Font = new PdfTrueTypeFont(new Font("Arial", 10f, FontStyle.Regular | FontStyle.Regular), true);
row21.Cells[1].StringFormat = new PdfStringFormat(PdfTextAlignment.Left, PdfVerticalAlignment.Top);
//row21.Cells[1].RowSpan = 2;
row21.Cells[1].Style.Borders = borderBotttom1;

if (isHideScore)
{
row21.Cells[2].Value = "";
}
else
{
row21.Cells[2].Value = isHideScore ? "" : item.PostScore.ToString();
}
row21.Cells[2].Style.Font = new PdfTrueTypeFont(new Font("Arial", 10f, FontStyle.Regular | FontStyle.Regular), true);
row21.Cells[2].StringFormat = new PdfStringFormat(PdfTextAlignment.Center, PdfVerticalAlignment.Middle);
//row21.Cells[2].RowSpan = 2;
row21.Cells[2].Style.Borders = borderBotttom1;


}
}

PdfGridRow row22 = grid.Rows.Add();
row22.Height = 25.0f;
row22.Cells[0].Value = "Total Score for Technical Knowledge (A)";
row22.Cells[0].Style.Font = new PdfTrueTypeFont(new Font("Mary Ann", 11f, FontStyle.Bold | FontStyle.Regular), true);
row22.Cells[0].StringFormat = new PdfStringFormat(PdfTextAlignment.Left, PdfVerticalAlignment.Middle);
row22.Cells[0].ColumnSpan = 2;
row22.Cells[2].Value = isHideScore ? "" : totalA.ToString();
row22.Cells[2].Style.Font = new PdfTrueTypeFont(new Font("Mary Ann", 11f, FontStyle.Bold | FontStyle.Regular), true);
row22.Cells[2].StringFormat = new PdfStringFormat(PdfTextAlignment.Center, PdfVerticalAlignment.Middle);
//row22.Cells[2].Style.BackgroundBrush = PdfBrushes.Yellow;

// value/behavious
PdfGridRow row23 = grid.Rows.Add();
PdfGridRow row24 = grid.Rows.Add();
PdfGridRow row25 = grid.Rows.Add();

row23.Cells[0].Value = "Area";
row23.Cells[0].Style.Font = new PdfTrueTypeFont(new Font("Mary Ann", 10f, FontStyle.Bold | FontStyle.Regular), true);
row23.Cells[0].StringFormat = new PdfStringFormat(PdfTextAlignment.Center, PdfVerticalAlignment.Middle);
row23.Cells[0].Style.Borders = borderBotttom1;
row23.Cells[1].Value = "Evidence";
row23.Cells[1].Style.Font = new PdfTrueTypeFont(new Font("Mary Ann", 10f, FontStyle.Bold | FontStyle.Regular), true);
row23.Cells[1].StringFormat = new PdfStringFormat(PdfTextAlignment.Center, PdfVerticalAlignment.Middle);
row23.Cells[1].Style.Borders = borderBotttom1;
row23.Cells[2].Value = "Colleague’s Score";
row23.Cells[2].Style.Font = new PdfTrueTypeFont(new Font("Mary Ann", 10f, FontStyle.Bold | FontStyle.Regular), true);
row23.Cells[2].StringFormat = new PdfStringFormat(PdfTextAlignment.Center, PdfVerticalAlignment.Middle);
row23.Cells[2].RowSpan = 3;

row24.Cells[0].Value = "Value/Behaviour";
row24.Cells[0].Style.Font = new PdfTrueTypeFont(new Font("Mary Ann", 10f, FontStyle.Bold | FontStyle.Regular), true);
row24.Cells[0].StringFormat = new PdfStringFormat(PdfTextAlignment.Center, PdfVerticalAlignment.Middle);
row24.Cells[0].Style.Borders = borderTopBotttom1;
row24.Cells[1].Value = "3 evidence-based responses required for ‘Value/Behaviour’";
row24.Cells[1].Style.Font = new PdfTrueTypeFont(new Font("Arial", 8f, FontStyle.Regular | FontStyle.Regular), true);
row24.Cells[1].StringFormat = new PdfStringFormat(PdfTextAlignment.Center, PdfVerticalAlignment.Top);
row24.Cells[1].Style.Borders = borderTopBotttom1;

row25.Cells[0].Value = "(from role profile)";
row25.Cells[0].Style.Font = new PdfTrueTypeFont(new Font("Arial", 8f, FontStyle.Regular | FontStyle.Regular), true);
row25.Cells[0].StringFormat = new PdfStringFormat(PdfTextAlignment.Center, PdfVerticalAlignment.Top);
row25.Cells[0].Style.Borders = borderTop1;
row25.Cells[1].Value = "Line Manager Feedback";
row25.Cells[1].Style.Font = new PdfTrueTypeFont(new Font("Mary Ann", 10f, FontStyle.Regular | FontStyle.Regular), true);
row25.Cells[1].StringFormat = new PdfStringFormat(PdfTextAlignment.Center, PdfVerticalAlignment.Middle);

if (assessmentColleagueViewModel != null)
{
foreach (var item in assessmentColleagueViewModel.BehaviourAssessmentDetails)
{
//string titleDescription = item.Title + " " + item.Description;
//PdfGridRow row26 = grid.Rows.Add();
//if (string.IsNullOrEmpty(item.Description) || titleDescription.Length < 100)
//{
// row26.Height = 60.0f;
//}
StringBuilder titledescription1 = new StringBuilder();
titledescription1.Append(item.Title);
titledescription1.Append(System.Environment.NewLine);
titledescription1.Append(item.Description);
float titledescriptionRowHeight = GetTitleRowHeight(titledescription1.ToString());
float feedbackRowHeight = GetFeedbackRowHeight(item.Feedback);
float finalRowHeight = 0;
if (feedbackRowHeight > titledescriptionRowHeight)
{
finalRowHeight = feedbackRowHeight;
}
else
{
finalRowHeight = titledescriptionRowHeight;
}

PdfGridRow row26 = grid.Rows.Add();
row26.Height = finalRowHeight;
//PdfGridRow row262 = grid.Rows.Add();

row26.Cells[0].Value = titledescription1.ToString();
row26.Cells[0].Style.Font = new PdfTrueTypeFont(new Font("Arial", 10f, FontStyle.Regular | FontStyle.Regular), true);
row26.Cells[0].StringFormat = new PdfStringFormat(PdfTextAlignment.Left, PdfVerticalAlignment.Top);
row26.Cells[0].Style.Borders = borderBotttom1;

//row262.Cells[0].Value = item.Description;
//row262.Cells[0].Style.Font = new PdfTrueTypeFont(new Font("Arial", 10f, FontStyle.Regular | FontStyle.Regular), true);
//row262.Cells[0].StringFormat = new PdfStringFormat(PdfTextAlignment.Left, PdfVerticalAlignment.Top);
//row262.Cells[0].Style.Borders = borderTop1;
//if (string.IsNullOrEmpty(item.Description) || item.Description.Length < 100)
//{
// row262.Height = 60.0f;
//}

row26.Cells[1].Value = item.Feedback;
row26.Cells[1].Style.Font = new PdfTrueTypeFont(new Font("Arial", 10f, FontStyle.Regular | FontStyle.Regular), true);
row26.Cells[1].StringFormat = new PdfStringFormat(PdfTextAlignment.Left, PdfVerticalAlignment.Top);
//row26.Cells[1].RowSpan = 2;

if (isHideScore)
{
row26.Cells[2].Value = "";
}
else
{
row26.Cells[2].Value = isHideScore ? "" : item.PostScore.ToString();
}
row26.Cells[2].Style.Font = new PdfTrueTypeFont(new Font("Arial", 10f, FontStyle.Regular | FontStyle.Regular), true);
row26.Cells[2].StringFormat = new PdfStringFormat(PdfTextAlignment.Center, PdfVerticalAlignment.Middle);
//row26.Cells[2].RowSpan = 2;


}
}

PdfGridRow row27 = grid.Rows.Add();
row27.Height = 25.0f;
row27.Cells[0].Value = "Total Score for Values/Behaviours (B) ";
row27.Cells[0].Style.Font = new PdfTrueTypeFont(new Font("Mary Ann", 11f, FontStyle.Bold | FontStyle.Regular), true);
row27.Cells[0].StringFormat = new PdfStringFormat(PdfTextAlignment.Right, PdfVerticalAlignment.Middle);
row27.Cells[0].ColumnSpan = 2;
row27.Cells[0].Style.CellPadding = new PdfPaddings(0, 6, 0, 0);
row27.Cells[2].Value = isHideScore ? "" : totalB.ToString();
row27.Cells[2].Style.Font = new PdfTrueTypeFont(new Font("Mary Ann", 11f, FontStyle.Bold | FontStyle.Regular), true);
row27.Cells[2].StringFormat = new PdfStringFormat(PdfTextAlignment.Center, PdfVerticalAlignment.Middle);
//row27.Cells[2].Style.BackgroundBrush = PdfBrushes.Yellow;

PdfGridRow row28 = grid.Rows.Add();
row28.Height = 25.0f;
row28.Cells[0].Value = "Match to new role score (A+B) ";
row28.Cells[0].Style.Font = new PdfTrueTypeFont(new Font("Mary Ann", 10f, FontStyle.Bold | FontStyle.Regular), true);
row28.Cells[0].StringFormat = new PdfStringFormat(PdfTextAlignment.Right, PdfVerticalAlignment.Middle);
row28.Cells[0].ColumnSpan = 2;
row28.Cells[0].Style.CellPadding = new PdfPaddings(0, 6, 0, 0);
row28.Cells[2].Value = isHideScore ? "" : totalAB.ToString();
row28.Cells[2].Style.Font = new PdfTrueTypeFont(new Font("Mary Ann", 11f, FontStyle.Bold | FontStyle.Regular), true);
row28.Cells[2].StringFormat = new PdfStringFormat(PdfTextAlignment.Center, PdfVerticalAlignment.Middle);
//row28.Cells[2].Style.BackgroundBrush = PdfBrushes.Yellow;

PdfGridRow row29 = grid.Rows.Add();
row29.Height = 15.0f;
row29.Cells[0].Value = "";
row29.Cells[0].ColumnSpan = 3;
row29.Cells[0].Style.Borders = borderLeftRight1;

PdfGridRow row30 = grid.Rows.Add();
row30.Height = 20.0f;
row30.Cells[0].Value = "Section 2 - Disciplinary Record";
row30.Cells[0].Style.Font = new PdfTrueTypeFont(new Font("Mary Ann", 11f, FontStyle.Bold | FontStyle.Bold), true);
row30.Cells[0].StringFormat = new PdfStringFormat(PdfTextAlignment.Center, PdfVerticalAlignment.Middle);
row30.Cells[0].Style.BackgroundBrush = PdfBrushes.LightGray;
row30.Cells[0].ColumnSpan = 3;

PdfGridRow row31 = grid.Rows.Add();
row31.Height = 25.0f;
row31.Cells[0].Value = "If a colleague has a 'live' disciplinary warning on file points will be deducted from the ‘match to role’ score before the final score is calculated.";
row31.Cells[0].StringFormat = new PdfStringFormat(PdfTextAlignment.Left, PdfVerticalAlignment.Top);
row31.Style.Font = new PdfTrueTypeFont(new Font("Arial", 10f, FontStyle.Regular | FontStyle.Regular), true);
row31.Cells[0].ColumnSpan = 3;
row31.Cells[0].Style.Borders = borderTopBotttom1;

PdfGridRow row311 = grid.Rows.Add();
row311.Height = 15.0f;
row311.Cells[0].Value = "If a colleague has more than one live warning, the warning of the highest level should be used.";
row311.Cells[0].StringFormat = new PdfStringFormat(PdfTextAlignment.Left, PdfVerticalAlignment.Top);
row311.Style.Font = new PdfTrueTypeFont(new Font("Arial", 10f, FontStyle.Regular | FontStyle.Regular), true);
row311.Cells[0].ColumnSpan = 3;
row311.Cells[0].Style.Borders = borderTopBotttom1;

PdfGridRow row312 = grid.Rows.Add();
row312.Height = 25.0f;
row312.Cells[0].Value = "Any disciplinary warning, whether for absence, conduct or performance, is relevant however; line managers should seek advice from your HR Change manager if an absence warning is linked to a disability.";
row312.Cells[0].StringFormat = new PdfStringFormat(PdfTextAlignment.Left, PdfVerticalAlignment.Top);
row312.Style.Font = new PdfTrueTypeFont(new Font("Arial", 10f, FontStyle.Regular | FontStyle.Regular), true);
row312.Cells[0].ColumnSpan = 3;
row312.Cells[0].Style.Borders = borderTopBotttom1;

PdfGridRow row313 = grid.Rows.Add();
row313.Height = 15.0f;
row313.Cells[0].Value = "The deduction should be made as follows:";
row313.Cells[0].StringFormat = new PdfStringFormat(PdfTextAlignment.Left, PdfVerticalAlignment.Top);
row313.Style.Font = new PdfTrueTypeFont(new Font("Arial", 10f, FontStyle.Regular | FontStyle.Regular), true);
row313.Cells[0].ColumnSpan = 3;
row313.Cells[0].Style.Borders = borderTopBotttom1;

PdfGridRow row314 = grid.Rows.Add();
row314.Height = 15.0f;
row314.Cells[0].Value = "Written warning = - 4";
row314.Cells[0].StringFormat = new PdfStringFormat(PdfTextAlignment.Left, PdfVerticalAlignment.Top);
row314.Style.Font = new PdfTrueTypeFont(new Font("Arial", 10f, FontStyle.Regular | FontStyle.Regular), true);
row314.Cells[0].ColumnSpan = 3;
row314.Cells[0].Style.Borders = borderTopBotttom1;

PdfGridRow row315 = grid.Rows.Add();
row315.Height = 15.0f;
row315.Cells[0].Value = "Final written warning = -8";
row315.Cells[0].StringFormat = new PdfStringFormat(PdfTextAlignment.Left, PdfVerticalAlignment.Top);
row315.Style.Font = new PdfTrueTypeFont(new Font("Arial", 10f, FontStyle.Regular | FontStyle.Regular), true);
row315.Cells[0].ColumnSpan = 3;
row315.Cells[0].Style.Borders = borderTopBotttom1;

PdfGridRow row32 = grid.Rows.Add();
row32.Height = 20.0f;
row32.Cells[0].Value = "Written Warning - 4 Final Written Warning -8";
row32.Cells[0].StringFormat = new PdfStringFormat(PdfTextAlignment.Left, PdfVerticalAlignment.Middle);
row32.Style.Font = new PdfTrueTypeFont(new Font("Arial", 10f, FontStyle.Regular | FontStyle.Regular), true);
row32.Cells[0].ColumnSpan = 3;


PdfGridRow row33 = grid.Rows.Add();
row33.Height = 25.0f;
row33.Cells[0].Value = "Total (C) ";
row33.Cells[0].Style.Font = new PdfTrueTypeFont(new Font("Mary Ann", 10f, FontStyle.Bold | FontStyle.Regular), true);
row33.Cells[0].StringFormat = new PdfStringFormat(PdfTextAlignment.Right, PdfVerticalAlignment.Middle);
row33.Cells[0].ColumnSpan = 2;
row33.Cells[0].Style.CellPadding = new PdfPaddings(0, 6, 0, 0);
row33.Cells[2].Value = isHideScore ? "" : "-" + totalC.ToString();
row33.Cells[2].Style.Font = new PdfTrueTypeFont(new Font("Mary Ann", 11f, FontStyle.Bold | FontStyle.Regular), true);
row33.Cells[2].StringFormat = new PdfStringFormat(PdfTextAlignment.Center, PdfVerticalAlignment.Middle);
//row33.Cells[2].Style.BackgroundBrush = PdfBrushes.Yellow;


PdfGridRow row34 = grid.Rows.Add();
row34.Height = 15.0f;
row34.Cells[0].Value = "";
row34.Cells[0].ColumnSpan = 3;
row34.Cells[0].Style.Borders = borderLeftRight1;

PdfGridRow row35 = grid.Rows.Add();
row35.Height = 20.0f;
row35.Cells[0].Value = "Section 3 – Individual Assessment – Total Scoring";
row35.Cells[0].Style.Font = new PdfTrueTypeFont(new Font("Mary Ann", 11f, FontStyle.Bold | FontStyle.Bold), true);
row35.Cells[0].StringFormat = new PdfStringFormat(PdfTextAlignment.Center, PdfVerticalAlignment.Middle);
row35.Cells[0].Style.BackgroundBrush = PdfBrushes.LightGray;
row35.Cells[0].ColumnSpan = 3;


PdfGridRow row36 = grid.Rows.Add();
row36.Height = 20.0f;
row36.Cells[0].Value = "Area of Assessment Form";
row36.Cells[0].Style.Font = new PdfTrueTypeFont(new Font("Mary Ann", 10f, FontStyle.Bold | FontStyle.Regular), true);
row36.Cells[0].StringFormat = new PdfStringFormat(PdfTextAlignment.Left, PdfVerticalAlignment.Middle);
row36.Cells[0].ColumnSpan = 2;
row36.Cells[2].Value = "Score";
row36.Cells[2].Style.Font = new PdfTrueTypeFont(new Font("Mary Ann", 11f, FontStyle.Bold | FontStyle.Regular), true);
row36.Cells[2].StringFormat = new PdfStringFormat(PdfTextAlignment.Center, PdfVerticalAlignment.Middle);

PdfGridRow row37 = grid.Rows.Add();
row37.Height = 20.0f;
row37.Cells[0].Value = "Match to new role (max 24)";
row37.Cells[0].Style.Font = new PdfTrueTypeFont(new Font("Arial", 10f, FontStyle.Regular | FontStyle.Regular), true);
row37.Cells[0].StringFormat = new PdfStringFormat(PdfTextAlignment.Left, PdfVerticalAlignment.Middle);
row37.Cells[0].ColumnSpan = 2;
row37.Cells[2].Value = isHideScore ? "" : totalAB.ToString();
row37.Cells[2].Style.Font = new PdfTrueTypeFont(new Font("Arial", 11f, FontStyle.Regular | FontStyle.Regular), true);
row37.Cells[2].StringFormat = new PdfStringFormat(PdfTextAlignment.Center, PdfVerticalAlignment.Middle);

PdfGridRow row38 = grid.Rows.Add();
row38.Height = 20.0f;
row38.Cells[0].Value = "Disciplinary Record (max – 8)";
row38.Cells[0].Style.Font = new PdfTrueTypeFont(new Font("Arial", 10f, FontStyle.Regular | FontStyle.Regular), true);
row38.Cells[0].StringFormat = new PdfStringFormat(PdfTextAlignment.Left, PdfVerticalAlignment.Middle);
row38.Cells[0].ColumnSpan = 2;
row38.Cells[2].Value = isHideScore ? "" : "-" + totalC.ToString();
row38.Cells[2].Style.Font = new PdfTrueTypeFont(new Font("Arial", 11f, FontStyle.Regular | FontStyle.Regular), true);
row38.Cells[2].StringFormat = new PdfStringFormat(PdfTextAlignment.Center, PdfVerticalAlignment.Middle);

PdfGridRow row39 = grid.Rows.Add();
row39.Height = 25.0f;
row39.Cells[0].Value = "Total score (A+B - C) ";
row39.Cells[0].Style.Font = new PdfTrueTypeFont(new Font("Mary Ann", 10f, FontStyle.Bold | FontStyle.Regular), true);
row39.Cells[0].StringFormat = new PdfStringFormat(PdfTextAlignment.Right, PdfVerticalAlignment.Middle);
row39.Cells[0].ColumnSpan = 2;
row39.Cells[0].Style.CellPadding = new PdfPaddings(0, 6, 0, 0);
row39.Cells[2].Value = isHideScore ? "" : totalABC.ToString();
row39.Cells[2].Style.Font = new PdfTrueTypeFont(new Font("Mary Ann", 11f, FontStyle.Regular | FontStyle.Regular), true);
row39.Cells[2].StringFormat = new PdfStringFormat(PdfTextAlignment.Center, PdfVerticalAlignment.Middle);
//row39.Cells[2].Style.BackgroundBrush = PdfBrushes.Yellow;

if (assessmentType == AssessmentType.CAF)
{
PdfGridRow row40 = grid.Rows.Add();
row40.Height = 15.0f;
row40.Cells[0].Value = "Additional colleague Comments:";
row40.Cells[0].StringFormat = new PdfStringFormat(PdfTextAlignment.Left, PdfVerticalAlignment.Top);
row40.Style.Font = new PdfTrueTypeFont(new Font("Mary Ann", 10f, FontStyle.Bold | FontStyle.Regular), true);
row40.Cells[0].ColumnSpan = 3;

float addCommentRowHeight = GetAddCommentRowHeight(additionalComments);
PdfGridRow row401 = grid.Rows.Add();
row401.Height = addCommentRowHeight;
row401.Cells[0].Value = additionalComments;
row401.Cells[0].StringFormat = new PdfStringFormat(PdfTextAlignment.Left, PdfVerticalAlignment.Top);
row401.Style.Font = new PdfTrueTypeFont(new Font("Mary Ann", 10f, FontStyle.Regular | FontStyle.Regular), true);
row401.Cells[0].ColumnSpan = 3;
row401.Cells[0].Style.Borders = borderTop1;


}
if (assessmentType == AssessmentType.DAF)
{
}

//PdfGridRow row41 = grid.Rows.Add();
//row41.Height = 20.0f;
//row41.Cells[0].Value = "Line Manager completing form";
//row41.Cells[0].Style.Font = new PdfTrueTypeFont(new Font("Arial", 10f, FontStyle.Regular | FontStyle.Regular), true);
//row41.Cells[0].StringFormat = new PdfStringFormat(PdfTextAlignment.Left, PdfVerticalAlignment.Middle);
//row41.Cells[1].Value = "";
//row41.Cells[1].Style.Font = new PdfTrueTypeFont(new Font("Arial", 10f, FontStyle.Regular | FontStyle.Regular), true);
//row41.Cells[1].StringFormat = new PdfStringFormat(PdfTextAlignment.Left, PdfVerticalAlignment.Middle);
//row41.Cells[1].ColumnSpan = 2;

//PdfGridRow row42 = grid.Rows.Add();
//row42.Height = 20.0f;
//row42.Cells[0].Value = "Date";
//row42.Cells[0].Style.Font = new PdfTrueTypeFont(new Font("Arial", 10f, FontStyle.Regular | FontStyle.Regular), true);
//row42.Cells[0].StringFormat = new PdfStringFormat(PdfTextAlignment.Left, PdfVerticalAlignment.Middle);
//row42.Cells[1].Value = "";
//row42.Cells[1].Style.Font = new PdfTrueTypeFont(new Font("Arial", 10f, FontStyle.Regular | FontStyle.Regular), true);
//row42.Cells[1].StringFormat = new PdfStringFormat(PdfTextAlignment.Left, PdfVerticalAlignment.Middle);
//row42.Cells[1].ColumnSpan = 2;

if (colleagueAssessmentId > 0)
{
var colleagueAssesmentEntity = await _colleagueAssessmentRepository.GetColleagueAssessmentByIdAsync(colleagueAssessmentId);
if (colleagueAssesmentEntity != null)
{
string signAknowlegement = "";
string signHeading = "";
string signPrintName = "";
string signDate = "";
PdfGridCellContentList lst = new PdfGridCellContentList();
PdfGridCellContent textAndStyle = new PdfGridCellContent();

if (colleagueAssesmentEntity.ColleagueSignOption == 1)
{
signAknowlegement = "Colleague Signature: I acknowledge that I have seen this form and have been given the opportunity to discuss and comment:";
signHeading = "Colleague Signature:";
signPrintName = colleagueName;
signDate = colleagueAssesmentEntity.ColleagueSignDated?.ToString("dd/MM/yyyy");
;
}
if (colleagueAssesmentEntity.ColleagueSignOption == 2)
{
signAknowlegement = "Manager Signature: I acknowledge that I have been given consent by the colleague to sign this form on their behalf.";
signHeading = "Manager Signature:";
signPrintName = colleagueName;
signDate = colleagueAssesmentEntity.ColleagueSignDated?.ToString("dd/MM/yyyy");
;
}
if (colleagueAssesmentEntity.ColleagueSignOption == 3)
{
signAknowlegement = "Colleague Signature: I acknowledge that I have seen this form and have been given the opportunity to discuss and comment:";
signHeading = "Colleague Signature:";
signPrintName = "";
signDate = "";
}

PdfGridRow row43 = grid.Rows.Add();
row43.Height = 20.0f;
row43.Cells[0].Value = signAknowlegement;
row43.Cells[0].Style.Font = new PdfTrueTypeFont(new Font("Arial", 10f, FontStyle.Regular | FontStyle.Regular), true);
row43.Cells[0].StringFormat = new PdfStringFormat(PdfTextAlignment.Left, PdfVerticalAlignment.Middle);
row43.Cells[0].ColumnSpan = 3;

PdfGridRow row44 = grid.Rows.Add();
row44.Height = 70.0f;
row44.Cells[0].Value = signHeading;
row44.Cells[0].Style.Font = new PdfTrueTypeFont(new Font("Arial", 10f, FontStyle.Regular | FontStyle.Regular), true);
row44.Cells[0].StringFormat = new PdfStringFormat(PdfTextAlignment.Left, PdfVerticalAlignment.Top);

if (!string.IsNullOrEmpty(colleagueAssesmentEntity.ColleagueSigned))
{
string base64 = colleagueAssesmentEntity.ColleagueSigned;
base64 = base64.Replace("data:image/png;base64,", "");
byte[] bytes = Convert.FromBase64String(base64);
Image image12;
using (MemoryStream ms = new MemoryStream(bytes))
{
image12 = Image.FromStream(ms);
}
PdfImage pdfImage = PdfImage.FromImage(image12);
textAndStyle.Image = pdfImage;
textAndStyle.ImageSize = new SizeF(60, 60);
lst.List.Add(textAndStyle);
}
if (colleagueAssesmentEntity.ColleagueSignOption == 3)
{
row44.Cells[1].Value = "Colleague refuses to sign";
row44.Cells[1].Style.Font = new PdfTrueTypeFont(new Font("Arial", 10f, FontStyle.Regular | FontStyle.Regular), true);
row44.Cells[1].StringFormat = new PdfStringFormat(PdfTextAlignment.Center, PdfVerticalAlignment.Middle);
row44.Cells[1].ColumnSpan = 2;
}
else
{
row44.Cells[1].Value = lst;
row44.Cells[1].Style.Font = new PdfTrueTypeFont(new Font("Arial", 10f, FontStyle.Regular | FontStyle.Regular), true);
row44.Cells[1].StringFormat = new PdfStringFormat(PdfTextAlignment.Center, PdfVerticalAlignment.Middle);
row44.Cells[1].ColumnSpan = 2;
}

PdfGridRow row45 = grid.Rows.Add();
row45.Height = 20.0f;
row45.Cells[0].Value = "Print name:";
row45.Cells[0].Style.Font = new PdfTrueTypeFont(new Font("Arial", 10f, FontStyle.Regular | FontStyle.Regular), true);
row45.Cells[0].StringFormat = new PdfStringFormat(PdfTextAlignment.Left, PdfVerticalAlignment.Middle);
row45.Cells[1].Value = signPrintName;
row45.Cells[1].Style.Font = new PdfTrueTypeFont(new Font("Arial", 10f, FontStyle.Regular | FontStyle.Regular), true);
row45.Cells[1].StringFormat = new PdfStringFormat(PdfTextAlignment.Left, PdfVerticalAlignment.Middle);
row45.Cells[1].ColumnSpan = 2;

PdfGridRow row46 = grid.Rows.Add();
row46.Height = 20.0f;
row46.Cells[0].Value = "Date:";
row46.Cells[0].Style.Font = new PdfTrueTypeFont(new Font("Arial", 10f, FontStyle.Regular | FontStyle.Regular), true);
row46.Cells[0].StringFormat = new PdfStringFormat(PdfTextAlignment.Left, PdfVerticalAlignment.Middle);
row46.Cells[1].Value = signDate;
row46.Cells[1].Style.Font = new PdfTrueTypeFont(new Font("Arial", 10f, FontStyle.Regular | FontStyle.Regular), true);
row46.Cells[1].StringFormat = new PdfStringFormat(PdfTextAlignment.Left, PdfVerticalAlignment.Middle);
row46.Cells[1].ColumnSpan = 2;

}
}

PdfLayoutResult result = grid.Draw(page, new PointF(0, y), gridLayout);
//y = result.Bounds.Bottom + 50;
y = y + result.Bounds.Height + 5;

MemoryStream stream = new MemoryStream();
pdf.SaveToStream(stream);
pdfTemplate = stream.ToArray();
pdf.Close();

return pdfTemplate;
}

tuleshkubde
 
Posts: 8
Joined: Tue Sep 06, 2022 5:35 pm

Fri Mar 15, 2024 2:43 am

Hello,

Thanks for your inquiry.
Sorry, because your code is too long and some parameters are unknown, I can't test it directly. But I speculate that the cause of your problem is that you set the bottom border of some cells to white, and these cells will appear lost at the page break. You can change white to other colors for debugging. If it still doesn't work, please provide us with a simplified code that can run directly and we will investigate further. Thanks in advance.

Sincerely,
William
E-iceblue support team
User avatar

William.Zhang
 
Posts: 203
Joined: Mon Dec 27, 2021 2:23 am

Fri Mar 15, 2024 2:22 pm

private int GetFeedbackRows(string title, string description)
{
string heading = title + description;
int feedbackRows = 5;
if (string.IsNullOrEmpty(heading) || heading.Length < 100)
{
feedbackRows = 5;
}
else
{
int factor = (heading.Length - 100) / 22;
feedbackRows = feedbackRows + factor;
}
return feedbackRows;
}
private float GetTitleRowHeight(string titledesc)
{
float rowHeight = 15.0f;
if (string.IsNullOrEmpty(titledesc) || titledesc.Length < 30)
{
rowHeight = 30.0f;
}
else
{
int factor = titledesc.Length / 25;
rowHeight = rowHeight * factor;
}
return rowHeight;
}
private float GetFeedbackRowHeight(string feedback)
{
float rowHeight = 15.0f;
if (string.IsNullOrEmpty(feedback) || feedback.Length < 64)
{
rowHeight = 15.0f;
}
else
{
int factor = feedback.Length / 60;
rowHeight = rowHeight * factor;
}
return rowHeight;
}
private float GetAddCommentRowHeight(string addcomment)
{
float rowHeight = 15.0f;
if (string.IsNullOrEmpty(addcomment) || addcomment.Length < 125)
{
rowHeight = 30.0f;
}
else
{
int factor = addcomment.Length / 50;
rowHeight = rowHeight * factor;
}
return rowHeight;
}

private async Task<byte[]> GeneratePdf()
{
byte[] pdfTemplate;

string rootPath = System.IO.Directory.GetCurrentDirectory();
var templatePath = Path.Combine(rootPath, "Template\\Blank.pdf");
PdfDocument pdf = new PdfDocument();

// Margins
PdfUnitConvertor unitCvtr = new PdfUnitConvertor();
PdfMargins margin = new PdfMargins();
margin.Top = 50;
margin.Bottom = 50;
margin.Left = 50;
margin.Right = 0;

pdf.AllowCreateForm = (pdf.Form == null) ? true : false;
PdfPageBase page = pdf.Pages.Add(PdfPageSize.A4, margin, PdfPageRotateAngle.RotateAngle0, PdfPageOrientation.Portrait);


float y = 30;

PdfGrid grid = new PdfGrid();
grid.BeginPageLayout += new BeginPageLayoutEventHandler(grid_BeginPageLayout1);
PdfGridLayoutFormat gridLayout = new PdfGridLayoutFormat();
gridLayout.Break = PdfLayoutBreakType.FitElement;
gridLayout.Layout = PdfLayoutType.Paginate;

PdfGridStyle gridStyle = new PdfGridStyle();

PdfBorders borderAll = new PdfBorders();
borderAll.All = new PdfPen(Color.Black, 0f);

grid.Style.CellPadding = new PdfPaddings(6, 0, 0, 0);

grid.Columns.Add(3);
float width = page.Canvas.ClientSize.Width - (grid.Columns.Count + 1);
grid.Columns[0].Width = width * 0.25f;
grid.Columns[1].Width = width * 0.55f;
grid.Columns[2].Width = width * 0.18f;

PdfGridRow row0 = grid.Rows.Add();
PdfGridRow row1 = grid.Rows.Add();
PdfGridRow row2 = grid.Rows.Add();
PdfGridRow row3 = grid.Rows.Add();
PdfGridRow row4 = grid.Rows.Add();
PdfGridRow row5 = grid.Rows.Add();
PdfGridRow row6 = grid.Rows.Add();
PdfGridRow row7 = grid.Rows.Add();
PdfGridRow row8 = grid.Rows.Add();
PdfGridRow row9 = grid.Rows.Add();
PdfGridRow row10 = grid.Rows.Add();
PdfGridRow row11 = grid.Rows.Add();
PdfGridRow row12 = grid.Rows.Add();
PdfGridRow row13 = grid.Rows.Add();
PdfGridRow row14 = grid.Rows.Add();
PdfGridRow row15 = grid.Rows.Add();
PdfGridRow row16 = grid.Rows.Add();
PdfGridRow row17 = grid.Rows.Add();
float height = 20.0f;
for (int i = 0; i < grid.Rows.Count; i++)
{
grid.Rows[i].Height = height;
}


row0.Style.Font = new PdfTrueTypeFont(new Font("Arial", 16f, FontStyle.Bold), true);
row1.Style.Font = new PdfTrueTypeFont(new Font("Arial", 16f, FontStyle.Italic), true);

string heading = "Colleague Assessment Form";
string headingGuidanceNote = "Guidance Notes for completion of the Colleague Assessment Form (CAF)";
PdfBrush headingTextBrush = PdfBrushes.White;
PdfBrush headingBackgroundBrush = PdfBrushes.Red;

PdfRGBColor redColor = new PdfRGBColor(192, 0, 0);
PdfSolidBrush redColorBrush = new PdfSolidBrush(redColor);

row0.Cells[0].Value = heading;
row0.Cells[0].Style.Font = new PdfTrueTypeFont(new Font("Mary Ann", 11f, FontStyle.Bold | FontStyle.Bold), true);
row0.Cells[0].Style.TextBrush = headingTextBrush;
row0.Cells[0].StringFormat = new PdfStringFormat(PdfTextAlignment.Center, PdfVerticalAlignment.Middle);
row0.Cells[0].Style.BackgroundBrush = headingBackgroundBrush;
row0.Cells[0].ColumnSpan = 3;

row1.Cells[0].Value = "Colleague name:";
row1.Cells[0].Style.Font = new PdfTrueTypeFont(new Font("Mary Ann", 10f, FontStyle.Bold | FontStyle.Regular), true);
row1.Cells[0].StringFormat = new PdfStringFormat(PdfTextAlignment.Left, PdfVerticalAlignment.Middle);
row1.Cells[1].Value = "test";
row1.Cells[1].Style.Font = new PdfTrueTypeFont(new Font("Mary Ann", 10f, FontStyle.Bold | FontStyle.Regular), true);
row1.Cells[1].StringFormat = new PdfStringFormat(PdfTextAlignment.Left, PdfVerticalAlignment.Middle);
row1.Cells[1].ColumnSpan = 2;

row2.Cells[0].Value = "Consultation manager:";
row2.Cells[0].Style.Font = new PdfTrueTypeFont(new Font("Mary Ann", 10f, FontStyle.Bold | FontStyle.Regular), true);
row2.Cells[0].StringFormat = new PdfStringFormat(PdfTextAlignment.Left, PdfVerticalAlignment.Middle);
row2.Cells[1].Value = "test";
row2.Cells[1].Style.Font = new PdfTrueTypeFont(new Font("Mary Ann", 10f, FontStyle.Bold | FontStyle.Regular), true);
row2.Cells[1].StringFormat = new PdfStringFormat(PdfTextAlignment.Left, PdfVerticalAlignment.Middle);
row2.Cells[1].ColumnSpan = 2;

row3.Cells[0].Value = "Colleague grade:";
row3.Cells[0].Style.Font = new PdfTrueTypeFont(new Font("Mary Ann", 10f, FontStyle.Bold | FontStyle.Regular), true);
row3.Cells[0].StringFormat = new PdfStringFormat(PdfTextAlignment.Left, PdfVerticalAlignment.Middle);
row3.Cells[1].Value = "test";
row3.Cells[1].Style.Font = new PdfTrueTypeFont(new Font("Mary Ann", 10f, FontStyle.Bold | FontStyle.Regular), true);
row3.Cells[1].StringFormat = new PdfStringFormat(PdfTextAlignment.Left, PdfVerticalAlignment.Middle);
row3.Cells[1].ColumnSpan = 2;

row4.Cells[0].Value = "Date completed:";
row4.Cells[0].Style.Font = new PdfTrueTypeFont(new Font("Mary Ann", 10f, FontStyle.Bold | FontStyle.Regular), true);
row4.Cells[0].StringFormat = new PdfStringFormat(PdfTextAlignment.Left, PdfVerticalAlignment.Middle);
row4.Cells[1].Value = "test";
row4.Cells[1].Style.Font = new PdfTrueTypeFont(new Font("Mary Ann", 10f, FontStyle.Bold | FontStyle.Regular), true);
row4.Cells[1].StringFormat = new PdfStringFormat(PdfTextAlignment.Left, PdfVerticalAlignment.Middle);
row4.Cells[1].ColumnSpan = 2;

row5.Cells[0].Value = "Colleague job title:";
row5.Cells[0].Style.Font = new PdfTrueTypeFont(new Font("Mary Ann", 10f, FontStyle.Bold | FontStyle.Regular), true);
row5.Cells[0].StringFormat = new PdfStringFormat(PdfTextAlignment.Left, PdfVerticalAlignment.Middle);
row5.Cells[1].Value = "test";
row5.Cells[1].Style.Font = new PdfTrueTypeFont(new Font("Mary Ann", 10f, FontStyle.Bold | FontStyle.Regular), true);
row5.Cells[1].StringFormat = new PdfStringFormat(PdfTextAlignment.Left, PdfVerticalAlignment.Middle);
row5.Cells[1].ColumnSpan = 2;

row6.Cells[0].Value = "Role being assessed against:";
row6.Cells[0].Style.Font = new PdfTrueTypeFont(new Font("Mary Ann", 10f, FontStyle.Bold | FontStyle.Regular), true);
row6.Cells[0].StringFormat = new PdfStringFormat(PdfTextAlignment.Left, PdfVerticalAlignment.Middle);
row6.Cells[1].Value = "test";
row6.Cells[1].Style.Font = new PdfTrueTypeFont(new Font("Mary Ann", 10f, FontStyle.Bold | FontStyle.Regular), true);
row6.Cells[1].StringFormat = new PdfStringFormat(PdfTextAlignment.Left, PdfVerticalAlignment.Middle);
row6.Cells[1].ColumnSpan = 2;

row7.Cells[0].Value = headingGuidanceNote;
row7.Cells[0].Style.Font = new PdfTrueTypeFont(new Font("Mary Ann", 11f, FontStyle.Bold | FontStyle.Bold), true);
row7.Cells[0].Style.TextBrush = headingTextBrush;
row7.Cells[0].StringFormat = new PdfStringFormat(PdfTextAlignment.Center, PdfVerticalAlignment.Middle);
row7.Cells[0].Style.BackgroundBrush = headingBackgroundBrush;
row7.Cells[0].ColumnSpan = 3;

row8.Cells[0].Value = "Section 1 - Match with Role";
row8.Cells[0].Style.Font = new PdfTrueTypeFont(new Font("Mary Ann", 11f, FontStyle.Bold | FontStyle.Bold), true);
row8.Cells[0].StringFormat = new PdfStringFormat(PdfTextAlignment.Center, PdfVerticalAlignment.Middle);
row8.Cells[0].Style.BackgroundBrush = PdfBrushes.LightGray;
row8.Cells[0].ColumnSpan = 3;


PdfBorders borderBotttom = new PdfBorders();
borderBotttom.Bottom = new PdfPen(Color.White);
borderBotttom.Top = new PdfPen(Color.White);


grid.Rows[9].Height = 30.0f;
row9.Cells[0].Value = "Colleagues should be informed during their first individual consultation meeting of the 3 ’Technical Knowledge' and 3 'Value/Behaviours' areas of the role profile that will be used as assessment criteria";
row9.Cells[0].StringFormat = new PdfStringFormat(PdfTextAlignment.Left, PdfVerticalAlignment.Middle);
row9.Style.Font = new PdfTrueTypeFont(new Font("Arial", 10f, FontStyle.Regular | FontStyle.Regular), true);
row9.Cells[0].ColumnSpan = 3;
row9.Cells[0].Style.Borders = borderBotttom;


grid.Rows[10].Height = 80.0f;
row10.Cells[0].Value = "Colleagues should be provided with a blank copy of an assessment form with the criteria, should the colleague wish to prepare a self-assessment. If a colleague does wish to complete a self-assessment, they should bring this to their second consultation meeting. During this meeting, the line manager should acknowledge the colleague’s evidence and consider this as part of the assessment. The line manager owns the wording on the CAF form, therefore has final say on the evidence that will be included in the last version. The review period for the assessment should be 12 months.";
row10.Cells[0].StringFormat = new PdfStringFormat(PdfTextAlignment.Left, PdfVerticalAlignment.Middle);
row10.Style.Font = new PdfTrueTypeFont(new Font("Arial", 10f, FontStyle.Regular | FontStyle.Regular), true);
row10.Cells[0].ColumnSpan = 3;
row10.Cells[0].Style.Borders = borderBotttom;



grid.Rows[11].Height = 30.0f;
row11.Cells[0].Value = "The line manager completing this form should score the colleague for each Technical Knowledge and Value/Behaviour criteria, as follows:";
row11.Cells[0].StringFormat = new PdfStringFormat(PdfTextAlignment.Left, PdfVerticalAlignment.Middle);
row11.Style.Font = new PdfTrueTypeFont(new Font("Arial", 10f, FontStyle.Regular | FontStyle.Regular), true);
row11.Cells[0].ColumnSpan = 3;
row11.Cells[0].Style.Borders = borderBotttom;


//-------------Create another grid to embed
//PdfGrid embedGrid = new PdfGrid();
//embedGrid.Style.CellPadding = new PdfPaddings(6, 0, 0, 0);
//PdfGridRow newRow0 = embedGrid.Rows.Add();
//PdfGridRow newRow1 = embedGrid.Rows.Add();
//PdfGridRow newRow2 = embedGrid.Rows.Add();
//PdfGridRow newRow3 = embedGrid.Rows.Add();
//PdfGridRow newRow4 = embedGrid.Rows.Add();
//PdfGridRow newRow5 = embedGrid.Rows.Add();
//embedGrid.Columns.Add(2);
//embedGrid.Columns[0].Width = 70f;
//embedGrid.Columns[1].Width = 470f;

//newRow0.Cells[0].Value = "Score";
//newRow0.Cells[0].StringFormat = new PdfStringFormat(PdfTextAlignment.Center, PdfVerticalAlignment.Middle);
//newRow0.Cells[0].Style.BackgroundBrush = PdfBrushes.LightGray;
//newRow0.Cells[1].Value = "Description";
//newRow0.Cells[1].StringFormat = new PdfStringFormat(PdfTextAlignment.Center, PdfVerticalAlignment.Middle);
//newRow0.Cells[1].Style.BackgroundBrush = PdfBrushes.LightGray;
//newRow0.Style.Font = new PdfTrueTypeFont(new Font("Arial", 10f, FontStyle.Bold | FontStyle.Regular), true);


//newRow1.Cells[0].Value = "0";
//newRow1.Cells[0].StringFormat = new PdfStringFormat(PdfTextAlignment.Center, PdfVerticalAlignment.Middle);
//newRow1.Cells[1].Value = "Colleague does not meet the expectations of the criteria, with no or negative evidence ";
//newRow1.Cells[1].StringFormat = new PdfStringFormat(PdfTextAlignment.Left, PdfVerticalAlignment.Middle);
//newRow1.Style.Font = new PdfTrueTypeFont(new Font("Arial", 10f, FontStyle.Regular | FontStyle.Regular), true);

//newRow2.Cells[0].Value = "1";
//newRow2.Cells[0].StringFormat = new PdfStringFormat(PdfTextAlignment.Center, PdfVerticalAlignment.Middle);
//newRow2.Cells[1].Value = "Colleague meets some of the expectations of the criteria, with some positive evidence but the majority are negative or opportunities ";
//newRow2.Cells[1].StringFormat = new PdfStringFormat(PdfTextAlignment.Left, PdfVerticalAlignment.Middle);
//newRow2.Style.Font = new PdfTrueTypeFont(new Font("Arial", 10f, FontStyle.Regular | FontStyle.Regular), true);

//newRow3.Cells[0].Value = "2";
//newRow3.Cells[0].StringFormat = new PdfStringFormat(PdfTextAlignment.Center, PdfVerticalAlignment.Middle);
//newRow3.Cells[1].Value = "Colleague meets most of the expectations of the criteria, with positive evidence and only minor opportunities";
//newRow3.Cells[1].StringFormat = new PdfStringFormat(PdfTextAlignment.Left, PdfVerticalAlignment.Middle);
//newRow3.Style.Font = new PdfTrueTypeFont(new Font("Arial", 10f, FontStyle.Regular | FontStyle.Regular), true);

//newRow4.Cells[0].Value = "3";
//newRow4.Cells[0].StringFormat = new PdfStringFormat(PdfTextAlignment.Center, PdfVerticalAlignment.Middle);
//newRow4.Cells[1].Value = "Colleague meets all the expectations of the criteria, with all positive evidence ";
//newRow4.Cells[1].StringFormat = new PdfStringFormat(PdfTextAlignment.Left, PdfVerticalAlignment.Middle);
//newRow4.Style.Font = new PdfTrueTypeFont(new Font("Arial", 10f, FontStyle.Regular | FontStyle.Regular), true);

//newRow5.Cells[0].Value = "4";
//newRow5.Cells[0].StringFormat = new PdfStringFormat(PdfTextAlignment.Center, PdfVerticalAlignment.Middle);
//newRow5.Cells[1].Value = "Colleague exceeds all the expectations of the criteria, with all incredibly positive and consistent evidence ";
//newRow5.Cells[1].StringFormat = new PdfStringFormat(PdfTextAlignment.Left, PdfVerticalAlignment.Middle);
//newRow5.Style.Font = new PdfTrueTypeFont(new Font("Arial", 10f, FontStyle.Regular | FontStyle.Regular), true);

//grid.Rows[12].Height = 125.0f;
//row12.Cells[0].Value = embedGrid;
//row12.Cells[0].ColumnSpan = 3;
//row12.Style.CellPadding = new PdfPaddings(6, 6, 6, 6);
//row12.Cells[0].Style.Borders = borderBotttom;
//-------------Create another grid to embed

grid.Rows[13].Height = 30.0f;
row13.Cells[0].Value = "The maximum total a colleague can score for this form is 24 points e.g. 3 areas of up to 4 points for Technical Knowledge (3x4) and 3 areas of up to 4 points for Value/Behaviours (3x4)";
row13.Cells[0].StringFormat = new PdfStringFormat(PdfTextAlignment.Left, PdfVerticalAlignment.Middle);
row13.Style.Font = new PdfTrueTypeFont(new Font("Arial", 10f, FontStyle.Regular | FontStyle.Regular), true);
row13.Cells[0].ColumnSpan = 3;
row13.Cells[0].Style.Borders = borderBotttom;

grid.Rows[14].Height = 30.0f;
row14.Cells[0].Value = "Line managers should use their own judgement and knowledge of the colleague to provide unambiguous evidence to support each Technical Knowledge and Value/Behaviour assessment criteria. ";
row14.Cells[0].StringFormat = new PdfStringFormat(PdfTextAlignment.Left, PdfVerticalAlignment.Middle);
row14.Style.Font = new PdfTrueTypeFont(new Font("Arial", 10f, FontStyle.Regular | FontStyle.Regular), true);
row14.Cells[0].ColumnSpan = 3;
row14.Cells[0].Style.Borders = borderBotttom;

grid.Rows[15].Height = 30.0f;
row15.Cells[0].Value = "Whist completing the form please consider the minimum performance standards alongside the role profile and requirements of the role. ";
row15.Cells[0].StringFormat = new PdfStringFormat(PdfTextAlignment.Left, PdfVerticalAlignment.Middle);
row15.Style.Font = new PdfTrueTypeFont(new Font("Arial", 10f, FontStyle.Regular | FontStyle.Regular), true);
row15.Cells[0].ColumnSpan = 3;
row15.Cells[0].Style.Borders = borderBotttom;


grid.Rows[16].Height = 40.0f;
row16.Cells[0].Value = "The highest scoring colleague(s) will be offered the role. Where we are not able to differentiate between scores, an interview process may take place. ";
row16.Cells[0].StringFormat = new PdfStringFormat(PdfTextAlignment.Left, PdfVerticalAlignment.Middle);
row16.Style.Font = new PdfTrueTypeFont(new Font("Arial", 10f, FontStyle.Regular | FontStyle.Regular), true);
row16.Cells[0].ColumnSpan = 3;
row16.Cells[0].Style.Borders = borderBotttom;


row17.Cells[0].Value = "Does Not Meet = 0 points, Meets some = 1 points, Meets most = 2 points, Meets all = 3 points, Exceeds = 4 points ";
row17.Cells[0].StringFormat = new PdfStringFormat(PdfTextAlignment.Left, PdfVerticalAlignment.Middle);
row17.Style.Font = new PdfTrueTypeFont(new Font("Arial", 10f, FontStyle.Regular | FontStyle.Regular), true);
row17.Cells[0].ColumnSpan = 3;

PdfBorders borderBotttom1 = new PdfBorders();
borderBotttom1.Bottom = new PdfPen(Color.White);
PdfBorders borderTop1 = new PdfBorders();
borderTop1.Top = new PdfPen(Color.White);
PdfBorders borderRight1 = new PdfBorders();
borderRight1.Right = new PdfPen(Color.White);
PdfBorders borderLeft1 = new PdfBorders();
borderLeft1.Left = new PdfPen(Color.White);

PdfBorders borderTopBotttom1 = new PdfBorders();
borderTopBotttom1.Top = new PdfPen(Color.White);
borderTopBotttom1.Bottom = new PdfPen(Color.White);
PdfBorders borderLeftRight1 = new PdfBorders();
borderLeftRight1.Left = new PdfPen(Color.White);
borderLeftRight1.Right = new PdfPen(Color.White);


// set rows
PdfGridRow row18 = grid.Rows.Add();
PdfGridRow row19 = grid.Rows.Add();
PdfGridRow row20 = grid.Rows.Add();

row18.Cells[0].Value = "Area";
row18.Cells[0].Style.Font = new PdfTrueTypeFont(new Font("Mary Ann", 10f, FontStyle.Bold | FontStyle.Regular), true);
row18.Cells[0].StringFormat = new PdfStringFormat(PdfTextAlignment.Center, PdfVerticalAlignment.Middle);
row18.Cells[0].Style.Borders = borderBotttom1;
row18.Cells[1].Value = "Evidence";
row18.Cells[1].Style.Font = new PdfTrueTypeFont(new Font("Mary Ann", 10f, FontStyle.Bold | FontStyle.Regular), true);
row18.Cells[1].StringFormat = new PdfStringFormat(PdfTextAlignment.Center, PdfVerticalAlignment.Middle);
row18.Cells[1].Style.Borders = borderBotttom1;
row18.Cells[2].Value = "Colleague’s Score";
row18.Cells[2].Style.Font = new PdfTrueTypeFont(new Font("Mary Ann", 10f, FontStyle.Bold | FontStyle.Regular), true);
row18.Cells[2].StringFormat = new PdfStringFormat(PdfTextAlignment.Center, PdfVerticalAlignment.Middle);
row18.Cells[2].RowSpan = 3;

row19.Cells[0].Value = "Technical Knowledge";
row19.Cells[0].Style.Font = new PdfTrueTypeFont(new Font("Mary Ann", 10f, FontStyle.Bold | FontStyle.Regular), true);
row19.Cells[0].StringFormat = new PdfStringFormat(PdfTextAlignment.Center, PdfVerticalAlignment.Middle);
row19.Cells[0].Style.Borders = borderTopBotttom1;
row19.Cells[1].Value = "3 evidence-based responses required for ‘Technical Knowledge’";
row19.Cells[1].Style.Font = new PdfTrueTypeFont(new Font("Arial", 8f, FontStyle.Regular | FontStyle.Regular), true);
row19.Cells[1].StringFormat = new PdfStringFormat(PdfTextAlignment.Center, PdfVerticalAlignment.Top);
row19.Cells[1].Style.Borders = borderTopBotttom1;

row20.Cells[0].Value = "(from role profile)";
row20.Cells[0].Style.Font = new PdfTrueTypeFont(new Font("Arial", 8f, FontStyle.Regular | FontStyle.Regular), true);
row20.Cells[0].StringFormat = new PdfStringFormat(PdfTextAlignment.Center, PdfVerticalAlignment.Top);
row20.Cells[0].Style.Borders = borderTop1;
row20.Cells[1].Value = "Line Manager Feedback";
row20.Cells[1].Style.Font = new PdfTrueTypeFont(new Font("Mary Ann", 10f, FontStyle.Regular | FontStyle.Regular), true);
row20.Cells[1].StringFormat = new PdfStringFormat(PdfTextAlignment.Center, PdfVerticalAlignment.Middle);

List<TestViewModel> testViewModelList = new List<TestViewModel>();
for (int i = 0; i < 3; i++)
{
TestViewModel testViewModel = new TestViewModel();
testViewModel.Title = "Line managers should";
testViewModel.Description = "Line managers should use their own judgement and knowledge of the colleague to provide unambiguous evidence to support each Technical Knowledge and Value/Behaviour assessment criteria. Colleague exceeds all the expectations of the criteria, with all incredibly positive and consistent evidenceColleague exceeds all the expectations of the criteria, with all incredibly positive and consistent evidenceLine managers should use their own judgement a";
testViewModel.PostScore = 0;
testViewModel.Feedback = "Line managers should use their own judgement and knowledge of the colleague to provide unambiguous evidence to support each Technical Knowledge and Value/Behaviour assessment criteria. Colleague exceeds all the expectations of the criteria, with all incredibly positive and consistent evidenceColleague exceeds all the expectations of the criteria, with all incredibly positive and consistent evidenceLine managers should use their own judgement and knowledge of the colleague to provide unambiguous evidence to support each Technical Knowledge and Value/ Behaviour assessment criteria.Colleague exceeds all the expectations of the criteria, with all incredibly positive and consistent evidenceColleague exceeds all the expectations of the criteria, with all incredibly positive and consistent evidence";
testViewModelList.Add(testViewModel);
}

foreach (var item in testViewModelList)
{
StringBuilder titledescription = new StringBuilder();
titledescription.Append(item.Title);
titledescription.Append(System.Environment.NewLine);
titledescription.Append(item.Description);
float titledescriptionRowHeight = GetTitleRowHeight(titledescription.ToString());
float feedbackRowHeight = GetFeedbackRowHeight(item.Feedback);
float finalRowHeight = 0;
if (feedbackRowHeight > titledescriptionRowHeight)
{
finalRowHeight = feedbackRowHeight;
}
else
{
finalRowHeight = titledescriptionRowHeight;
}

PdfGridRow row21 = grid.Rows.Add();
row21.Height = finalRowHeight;
row21.Cells[0].Value = titledescription.ToString();
row21.Cells[0].Style.Font = new PdfTrueTypeFont(new Font("Arial", 10f, FontStyle.Regular | FontStyle.Regular), true);
row21.Cells[0].StringFormat = new PdfStringFormat(PdfTextAlignment.Left, PdfVerticalAlignment.Top);
row21.Cells[0].Style.Borders = borderBotttom1;


row21.Cells[1].Value = item.Feedback;
row21.Cells[1].Style.Font = new PdfTrueTypeFont(new Font("Arial", 10f, FontStyle.Regular | FontStyle.Regular), true);
row21.Cells[1].StringFormat = new PdfStringFormat(PdfTextAlignment.Left, PdfVerticalAlignment.Top);
row21.Cells[1].Style.Borders = borderBotttom1;
row21.Cells[2].Value = item.PostScore.ToString();

row21.Cells[2].Style.Font = new PdfTrueTypeFont(new Font("Arial", 10f, FontStyle.Regular | FontStyle.Regular), true);
row21.Cells[2].StringFormat = new PdfStringFormat(PdfTextAlignment.Center, PdfVerticalAlignment.Middle);
row21.Cells[2].Style.Borders = borderBotttom1;
}

PdfGridRow row22 = grid.Rows.Add();
row22.Height = 25.0f;
row22.Cells[0].Value = "Total Score for Technical Knowledge (A)";
row22.Cells[0].Style.Font = new PdfTrueTypeFont(new Font("Mary Ann", 11f, FontStyle.Bold | FontStyle.Regular), true);
row22.Cells[0].StringFormat = new PdfStringFormat(PdfTextAlignment.Left, PdfVerticalAlignment.Middle);
row22.Cells[0].ColumnSpan = 2;
row22.Cells[2].Value = "0";
row22.Cells[2].Style.Font = new PdfTrueTypeFont(new Font("Mary Ann", 11f, FontStyle.Bold | FontStyle.Regular), true);
row22.Cells[2].StringFormat = new PdfStringFormat(PdfTextAlignment.Center, PdfVerticalAlignment.Middle);

PdfGridRow row23 = grid.Rows.Add();
PdfGridRow row24 = grid.Rows.Add();
PdfGridRow row25 = grid.Rows.Add();

row23.Cells[0].Value = "Area";
row23.Cells[0].Style.Font = new PdfTrueTypeFont(new Font("Mary Ann", 10f, FontStyle.Bold | FontStyle.Regular), true);
row23.Cells[0].StringFormat = new PdfStringFormat(PdfTextAlignment.Center, PdfVerticalAlignment.Middle);
row23.Cells[0].Style.Borders = borderBotttom1;
row23.Cells[1].Value = "Evidence";
row23.Cells[1].Style.Font = new PdfTrueTypeFont(new Font("Mary Ann", 10f, FontStyle.Bold | FontStyle.Regular), true);
row23.Cells[1].StringFormat = new PdfStringFormat(PdfTextAlignment.Center, PdfVerticalAlignment.Middle);
row23.Cells[1].Style.Borders = borderBotttom1;
row23.Cells[2].Value = "Colleague’s Score";
row23.Cells[2].Style.Font = new PdfTrueTypeFont(new Font("Mary Ann", 10f, FontStyle.Bold | FontStyle.Regular), true);
row23.Cells[2].StringFormat = new PdfStringFormat(PdfTextAlignment.Center, PdfVerticalAlignment.Middle);
row23.Cells[2].RowSpan = 3;

row24.Cells[0].Value = "Value/Behaviour";
row24.Cells[0].Style.Font = new PdfTrueTypeFont(new Font("Mary Ann", 10f, FontStyle.Bold | FontStyle.Regular), true);
row24.Cells[0].StringFormat = new PdfStringFormat(PdfTextAlignment.Center, PdfVerticalAlignment.Middle);
row24.Cells[0].Style.Borders = borderTopBotttom1;
row24.Cells[1].Value = "3 evidence-based responses required for ‘Value/Behaviour’";
row24.Cells[1].Style.Font = new PdfTrueTypeFont(new Font("Arial", 8f, FontStyle.Regular | FontStyle.Regular), true);
row24.Cells[1].StringFormat = new PdfStringFormat(PdfTextAlignment.Center, PdfVerticalAlignment.Top);
row24.Cells[1].Style.Borders = borderTopBotttom1;

row25.Cells[0].Value = "(from role profile)";
row25.Cells[0].Style.Font = new PdfTrueTypeFont(new Font("Arial", 8f, FontStyle.Regular | FontStyle.Regular), true);
row25.Cells[0].StringFormat = new PdfStringFormat(PdfTextAlignment.Center, PdfVerticalAlignment.Top);
row25.Cells[0].Style.Borders = borderTop1;
row25.Cells[1].Value = "Line Manager Feedback";
row25.Cells[1].Style.Font = new PdfTrueTypeFont(new Font("Mary Ann", 10f, FontStyle.Regular | FontStyle.Regular), true);
row25.Cells[1].StringFormat = new PdfStringFormat(PdfTextAlignment.Center, PdfVerticalAlignment.Middle);

foreach (var item in testViewModelList)
{
StringBuilder titledescription1 = new StringBuilder();
titledescription1.Append(item.Title);
titledescription1.Append(System.Environment.NewLine);
titledescription1.Append(item.Description);
float titledescriptionRowHeight = GetTitleRowHeight(titledescription1.ToString());
float feedbackRowHeight = GetFeedbackRowHeight(item.Feedback);
float finalRowHeight = 0;
if (feedbackRowHeight > titledescriptionRowHeight)
{
finalRowHeight = feedbackRowHeight;
}
else
{
finalRowHeight = titledescriptionRowHeight;
}

PdfGridRow row26 = grid.Rows.Add();
row26.Height = finalRowHeight;
row26.Cells[0].Value = titledescription1.ToString();
row26.Cells[0].Style.Font = new PdfTrueTypeFont(new Font("Arial", 10f, FontStyle.Regular | FontStyle.Regular), true);
row26.Cells[0].StringFormat = new PdfStringFormat(PdfTextAlignment.Left, PdfVerticalAlignment.Top);
row26.Cells[0].Style.Borders = borderBotttom1;

row26.Cells[1].Value = item.Feedback;
row26.Cells[1].Style.Font = new PdfTrueTypeFont(new Font("Arial", 10f, FontStyle.Regular | FontStyle.Regular), true);
row26.Cells[1].StringFormat = new PdfStringFormat(PdfTextAlignment.Left, PdfVerticalAlignment.Top);
row26.Cells[2].Value = item.PostScore.ToString();
row26.Cells[2].Style.Font = new PdfTrueTypeFont(new Font("Arial", 10f, FontStyle.Regular | FontStyle.Regular), true);
row26.Cells[2].StringFormat = new PdfStringFormat(PdfTextAlignment.Center, PdfVerticalAlignment.Middle);
}

PdfGridRow row27 = grid.Rows.Add();
row27.Height = 25.0f;
row27.Cells[0].Value = "Total Score for Values/Behaviours (B) ";
row27.Cells[0].Style.Font = new PdfTrueTypeFont(new Font("Mary Ann", 11f, FontStyle.Bold | FontStyle.Regular), true);
row27.Cells[0].StringFormat = new PdfStringFormat(PdfTextAlignment.Right, PdfVerticalAlignment.Middle);
row27.Cells[0].ColumnSpan = 2;
row27.Cells[0].Style.CellPadding = new PdfPaddings(0, 6, 0, 0);
row27.Cells[2].Value = "0";
row27.Cells[2].Style.Font = new PdfTrueTypeFont(new Font("Mary Ann", 11f, FontStyle.Bold | FontStyle.Regular), true);
row27.Cells[2].StringFormat = new PdfStringFormat(PdfTextAlignment.Center, PdfVerticalAlignment.Middle);

PdfGridRow row28 = grid.Rows.Add();
row28.Height = 25.0f;
row28.Cells[0].Value = "Match to new role score (A+B) ";
row28.Cells[0].Style.Font = new PdfTrueTypeFont(new Font("Mary Ann", 10f, FontStyle.Bold | FontStyle.Regular), true);
row28.Cells[0].StringFormat = new PdfStringFormat(PdfTextAlignment.Right, PdfVerticalAlignment.Middle);
row28.Cells[0].ColumnSpan = 2;
row28.Cells[0].Style.CellPadding = new PdfPaddings(0, 6, 0, 0);
row28.Cells[2].Value = "0";
row28.Cells[2].Style.Font = new PdfTrueTypeFont(new Font("Mary Ann", 11f, FontStyle.Bold | FontStyle.Regular), true);
row28.Cells[2].StringFormat = new PdfStringFormat(PdfTextAlignment.Center, PdfVerticalAlignment.Middle);

PdfGridRow row29 = grid.Rows.Add();
row29.Height = 15.0f;
row29.Cells[0].Value = "";
row29.Cells[0].ColumnSpan = 3;
row29.Cells[0].Style.Borders = borderLeftRight1;

PdfGridRow row30 = grid.Rows.Add();
row30.Height = 20.0f;
row30.Cells[0].Value = "Section 2 - Disciplinary Record";
row30.Cells[0].Style.Font = new PdfTrueTypeFont(new Font("Mary Ann", 11f, FontStyle.Bold | FontStyle.Bold), true);
row30.Cells[0].StringFormat = new PdfStringFormat(PdfTextAlignment.Center, PdfVerticalAlignment.Middle);
row30.Cells[0].Style.BackgroundBrush = PdfBrushes.LightGray;
row30.Cells[0].ColumnSpan = 3;

PdfGridRow row31 = grid.Rows.Add();
row31.Height = 25.0f;
row31.Cells[0].Value = "If a colleague has a 'live' disciplinary warning on file points will be deducted from the ‘match to role’ score before the final score is calculated.";
row31.Cells[0].StringFormat = new PdfStringFormat(PdfTextAlignment.Left, PdfVerticalAlignment.Top);
row31.Style.Font = new PdfTrueTypeFont(new Font("Arial", 10f, FontStyle.Regular | FontStyle.Regular), true);
row31.Cells[0].ColumnSpan = 3;
row31.Cells[0].Style.Borders = borderTopBotttom1;

PdfGridRow row311 = grid.Rows.Add();
row311.Height = 15.0f;
row311.Cells[0].Value = "If a colleague has more than one live warning, the warning of the highest level should be used.";
row311.Cells[0].StringFormat = new PdfStringFormat(PdfTextAlignment.Left, PdfVerticalAlignment.Top);
row311.Style.Font = new PdfTrueTypeFont(new Font("Arial", 10f, FontStyle.Regular | FontStyle.Regular), true);
row311.Cells[0].ColumnSpan = 3;
row311.Cells[0].Style.Borders = borderTopBotttom1;

PdfGridRow row312 = grid.Rows.Add();
row312.Height = 25.0f;
row312.Cells[0].Value = "Any disciplinary warning, whether for absence, conduct or performance, is relevant however; line managers should seek advice from your HR Change manager if an absence warning is linked to a disability.";
row312.Cells[0].StringFormat = new PdfStringFormat(PdfTextAlignment.Left, PdfVerticalAlignment.Top);
row312.Style.Font = new PdfTrueTypeFont(new Font("Arial", 10f, FontStyle.Regular | FontStyle.Regular), true);
row312.Cells[0].ColumnSpan = 3;
row312.Cells[0].Style.Borders = borderTopBotttom1;

PdfGridRow row313 = grid.Rows.Add();
row313.Height = 15.0f;
row313.Cells[0].Value = "The deduction should be made as follows:";
row313.Cells[0].StringFormat = new PdfStringFormat(PdfTextAlignment.Left, PdfVerticalAlignment.Top);
row313.Style.Font = new PdfTrueTypeFont(new Font("Arial", 10f, FontStyle.Regular | FontStyle.Regular), true);
row313.Cells[0].ColumnSpan = 3;
row313.Cells[0].Style.Borders = borderTopBotttom1;

PdfGridRow row314 = grid.Rows.Add();
row314.Height = 15.0f;
row314.Cells[0].Value = "Written warning = - 4";
row314.Cells[0].StringFormat = new PdfStringFormat(PdfTextAlignment.Left, PdfVerticalAlignment.Top);
row314.Style.Font = new PdfTrueTypeFont(new Font("Arial", 10f, FontStyle.Regular | FontStyle.Regular), true);
row314.Cells[0].ColumnSpan = 3;
row314.Cells[0].Style.Borders = borderTopBotttom1;

PdfGridRow row315 = grid.Rows.Add();
row315.Height = 15.0f;
row315.Cells[0].Value = "Final written warning = -8";
row315.Cells[0].StringFormat = new PdfStringFormat(PdfTextAlignment.Left, PdfVerticalAlignment.Top);
row315.Style.Font = new PdfTrueTypeFont(new Font("Arial", 10f, FontStyle.Regular | FontStyle.Regular), true);
row315.Cells[0].ColumnSpan = 3;
row315.Cells[0].Style.Borders = borderTopBotttom1;

PdfGridRow row32 = grid.Rows.Add();
row32.Height = 20.0f;
row32.Cells[0].Value = "Written Warning - 4 Final Written Warning -8";
row32.Cells[0].StringFormat = new PdfStringFormat(PdfTextAlignment.Left, PdfVerticalAlignment.Middle);
row32.Style.Font = new PdfTrueTypeFont(new Font("Arial", 10f, FontStyle.Regular | FontStyle.Regular), true);
row32.Cells[0].ColumnSpan = 3;


PdfGridRow row33 = grid.Rows.Add();
row33.Height = 25.0f;
row33.Cells[0].Value = "Total (C) ";
row33.Cells[0].Style.Font = new PdfTrueTypeFont(new Font("Mary Ann", 10f, FontStyle.Bold | FontStyle.Regular), true);
row33.Cells[0].StringFormat = new PdfStringFormat(PdfTextAlignment.Right, PdfVerticalAlignment.Middle);
row33.Cells[0].ColumnSpan = 2;
row33.Cells[0].Style.CellPadding = new PdfPaddings(0, 6, 0, 0);
row33.Cells[2].Value = "0";
row33.Cells[2].Style.Font = new PdfTrueTypeFont(new Font("Mary Ann", 11f, FontStyle.Bold | FontStyle.Regular), true);
row33.Cells[2].StringFormat = new PdfStringFormat(PdfTextAlignment.Center, PdfVerticalAlignment.Middle);


PdfGridRow row34 = grid.Rows.Add();
row34.Height = 15.0f;
row34.Cells[0].Value = "";
row34.Cells[0].ColumnSpan = 3;
row34.Cells[0].Style.Borders = borderLeftRight1;

PdfGridRow row35 = grid.Rows.Add();
row35.Height = 20.0f;
row35.Cells[0].Value = "Section 3 – Individual Assessment – Total Scoring";
row35.Cells[0].Style.Font = new PdfTrueTypeFont(new Font("Mary Ann", 11f, FontStyle.Bold | FontStyle.Bold), true);
row35.Cells[0].StringFormat = new PdfStringFormat(PdfTextAlignment.Center, PdfVerticalAlignment.Middle);
row35.Cells[0].Style.BackgroundBrush = PdfBrushes.LightGray;
row35.Cells[0].ColumnSpan = 3;


PdfGridRow row36 = grid.Rows.Add();
row36.Height = 20.0f;
row36.Cells[0].Value = "Area of Assessment Form";
row36.Cells[0].Style.Font = new PdfTrueTypeFont(new Font("Mary Ann", 10f, FontStyle.Bold | FontStyle.Regular), true);
row36.Cells[0].StringFormat = new PdfStringFormat(PdfTextAlignment.Left, PdfVerticalAlignment.Middle);
row36.Cells[0].ColumnSpan = 2;
row36.Cells[2].Value = "Score";
row36.Cells[2].Style.Font = new PdfTrueTypeFont(new Font("Mary Ann", 11f, FontStyle.Bold | FontStyle.Regular), true);
row36.Cells[2].StringFormat = new PdfStringFormat(PdfTextAlignment.Center, PdfVerticalAlignment.Middle);

PdfGridRow row37 = grid.Rows.Add();
row37.Height = 20.0f;
row37.Cells[0].Value = "Match to new role (max 24)";
row37.Cells[0].Style.Font = new PdfTrueTypeFont(new Font("Arial", 10f, FontStyle.Regular | FontStyle.Regular), true);
row37.Cells[0].StringFormat = new PdfStringFormat(PdfTextAlignment.Left, PdfVerticalAlignment.Middle);
row37.Cells[0].ColumnSpan = 2;
row37.Cells[2].Value = "0";
row37.Cells[2].Style.Font = new PdfTrueTypeFont(new Font("Arial", 11f, FontStyle.Regular | FontStyle.Regular), true);
row37.Cells[2].StringFormat = new PdfStringFormat(PdfTextAlignment.Center, PdfVerticalAlignment.Middle);

PdfGridRow row38 = grid.Rows.Add();
row38.Height = 20.0f;
row38.Cells[0].Value = "Disciplinary Record (max – 8)";
row38.Cells[0].Style.Font = new PdfTrueTypeFont(new Font("Arial", 10f, FontStyle.Regular | FontStyle.Regular), true);
row38.Cells[0].StringFormat = new PdfStringFormat(PdfTextAlignment.Left, PdfVerticalAlignment.Middle);
row38.Cells[0].ColumnSpan = 2;
row38.Cells[2].Value = "0";
row38.Cells[2].Style.Font = new PdfTrueTypeFont(new Font("Arial", 11f, FontStyle.Regular | FontStyle.Regular), true);
row38.Cells[2].StringFormat = new PdfStringFormat(PdfTextAlignment.Center, PdfVerticalAlignment.Middle);

PdfGridRow row39 = grid.Rows.Add();
row39.Height = 25.0f;
row39.Cells[0].Value = "Total score (A+B - C) ";
row39.Cells[0].Style.Font = new PdfTrueTypeFont(new Font("Mary Ann", 10f, FontStyle.Bold | FontStyle.Regular), true);
row39.Cells[0].StringFormat = new PdfStringFormat(PdfTextAlignment.Right, PdfVerticalAlignment.Middle);
row39.Cells[0].ColumnSpan = 2;
row39.Cells[0].Style.CellPadding = new PdfPaddings(0, 6, 0, 0);
row39.Cells[2].Value = "0";
row39.Cells[2].Style.Font = new PdfTrueTypeFont(new Font("Mary Ann", 11f, FontStyle.Regular | FontStyle.Regular), true);
row39.Cells[2].StringFormat = new PdfStringFormat(PdfTextAlignment.Center, PdfVerticalAlignment.Middle);

PdfGridRow row40 = grid.Rows.Add();
row40.Height = 15.0f;
row40.Cells[0].Value = "Additional colleague Comments:";
row40.Cells[0].StringFormat = new PdfStringFormat(PdfTextAlignment.Left, PdfVerticalAlignment.Top);
row40.Style.Font = new PdfTrueTypeFont(new Font("Mary Ann", 10f, FontStyle.Bold | FontStyle.Regular), true);
row40.Cells[0].ColumnSpan = 3;

float addCommentRowHeight = GetAddCommentRowHeight("additionalComments");
PdfGridRow row401 = grid.Rows.Add();
row401.Height = addCommentRowHeight;
row401.Cells[0].Value = "additionalComments";
row401.Cells[0].StringFormat = new PdfStringFormat(PdfTextAlignment.Left, PdfVerticalAlignment.Top);
row401.Style.Font = new PdfTrueTypeFont(new Font("Mary Ann", 10f, FontStyle.Regular | FontStyle.Regular), true);
row401.Cells[0].ColumnSpan = 3;
row401.Cells[0].Style.Borders = borderTop1;

PdfGridCellContentList lst = new PdfGridCellContentList();
PdfGridCellContent textAndStyle = new PdfGridCellContent();

string signAknowlegement = "Colleague Signature: I acknowledge that I have seen this form and have been given the opportunity to discuss and comment:";
string signHeading = "Colleague Signature:";
string signPrintName = "";
string signDate = "";

PdfGridRow row43 = grid.Rows.Add();
row43.Height = 20.0f;
row43.Cells[0].Value = signAknowlegement;
row43.Cells[0].Style.Font = new PdfTrueTypeFont(new Font("Arial", 10f, FontStyle.Regular | FontStyle.Regular), true);
row43.Cells[0].StringFormat = new PdfStringFormat(PdfTextAlignment.Left, PdfVerticalAlignment.Middle);
row43.Cells[0].ColumnSpan = 3;

PdfGridRow row44 = grid.Rows.Add();
row44.Height = 70.0f;
row44.Cells[0].Value = signHeading;
row44.Cells[0].Style.Font = new PdfTrueTypeFont(new Font("Arial", 10f, FontStyle.Regular | FontStyle.Regular), true);
row44.Cells[0].StringFormat = new PdfStringFormat(PdfTextAlignment.Left, PdfVerticalAlignment.Top);

row44.Cells[1].Value = "Colleague refuses to sign";
row44.Cells[1].Style.Font = new PdfTrueTypeFont(new Font("Arial", 10f, FontStyle.Regular | FontStyle.Regular), true);
row44.Cells[1].StringFormat = new PdfStringFormat(PdfTextAlignment.Center, PdfVerticalAlignment.Middle);
row44.Cells[1].ColumnSpan = 2;

PdfGridRow row45 = grid.Rows.Add();
row45.Height = 20.0f;
row45.Cells[0].Value = "Print name:";
row45.Cells[0].Style.Font = new PdfTrueTypeFont(new Font("Arial", 10f, FontStyle.Regular | FontStyle.Regular), true);
row45.Cells[0].StringFormat = new PdfStringFormat(PdfTextAlignment.Left, PdfVerticalAlignment.Middle);
row45.Cells[1].Value = signPrintName;
row45.Cells[1].Style.Font = new PdfTrueTypeFont(new Font("Arial", 10f, FontStyle.Regular | FontStyle.Regular), true);
row45.Cells[1].StringFormat = new PdfStringFormat(PdfTextAlignment.Left, PdfVerticalAlignment.Middle);
row45.Cells[1].ColumnSpan = 2;

PdfGridRow row46 = grid.Rows.Add();
row46.Height = 20.0f;
row46.Cells[0].Value = "Date:";
row46.Cells[0].Style.Font = new PdfTrueTypeFont(new Font("Arial", 10f, FontStyle.Regular | FontStyle.Regular), true);
row46.Cells[0].StringFormat = new PdfStringFormat(PdfTextAlignment.Left, PdfVerticalAlignment.Middle);
row46.Cells[1].Value = signDate;
row46.Cells[1].Style.Font = new PdfTrueTypeFont(new Font("Arial", 10f, FontStyle.Regular | FontStyle.Regular), true);
row46.Cells[1].StringFormat = new PdfStringFormat(PdfTextAlignment.Left, PdfVerticalAlignment.Middle);
row46.Cells[1].ColumnSpan = 2;


PdfLayoutResult result = grid.Draw(page, new PointF(0, y), gridLayout);
y = y + result.Bounds.Height + 5;


MemoryStream stream = new MemoryStream();
pdf.SaveToStream(stream);
pdfTemplate = stream.ToArray();
pdf.Close();

return pdfTemplate;
}
static void grid_BeginPageLayout1(object sender, BeginPageLayoutEventArgs args)
{
}
public class TestViewModel
{
public string Title { get; set; }
public string Description { get; set; }
public int PostScore { get; set; }
public string Feedback { get; set; }

}

tuleshkubde
 
Posts: 8
Joined: Tue Sep 06, 2022 5:35 pm

Mon Mar 18, 2024 10:02 am

Hello,

Thanks for your reply.
As I explained before, because you set the border at the bottom of the cell at the page break to white, it appears to disappear. If you change "White" to "Red" in the code below, the border will reappear. I have uploaded my results file for your reference. To resolve this issue, you need to position the cells at the page break and change the color of their bottom border to black.
Code: Select all
PdfBorders borderBotttom1 = new PdfBorders();
// borderBotttom1.Bottom = new PdfPen(Color.White);
borderBotttom1.Bottom = new PdfPen(Color.Red);

Sincerely,
William
E-iceblue support team
User avatar

William.Zhang
 
Posts: 203
Joined: Mon Dec 27, 2021 2:23 am

Return to Spire.PDF

cron