PDFsharp & MigraDoc Foundation
https://forum.pdfsharp.net/

Value was either too large or too small for an unsigned byte
https://forum.pdfsharp.net/viewtopic.php?f=3&t=283
Page 1 of 1

Author:  pavalisoft [ Sat Dec 22, 2007 6:56 am ]
Post subject:  Value was either too large or too small for an unsigned byte

Hi,
While i am programmin using table using sharpDPF, i am getting the fillowing error "Value was either too large or too small for an unsigned byte."

the code for this is as follows...

pdfTable myTable = new pdfTable();
myTable.borderSize = 0;
myTable.borderColor = predefinedColor.csWhite;
myTable.cellpadding = 1;
myTable.tableHeaderStyle = new pdfTableRowStyle(predefinedFont.csHelvetica, 0, predefinedColor.csBlack, predefinedColor.csWhite);
myTable.rowStyle = new pdfTableRowStyle(predefinedFont.csHelvetica, 14, predefinedColor.csBlack, predefinedColor.csWhite);
myTable.tableHeader.addColumn(new pdfTableColumn("title", predefinedAlignment.csCenter, 570));

int titleCount = objProposalData.DsProposalData.Tables[0].Rows[0]["secondaryGoal"].ToString().Trim().Length;
int titleRows = (int)Math.Ceiling((double)titleCount / 64);
string[] titleStrings = new string[titleRows];
for (int i = 0; i < titleRows ; i++)
{
if (i == (titleRows - 1))
titleStrings[i] = objProposalData.DsProposalData.Tables[0].Rows[0]["secondaryGoal"].ToString().Substring(i * 64, titleCount - ((i * 64)));
else
{
if(i==0 & titleCount <=64)
titleStrings[i] = objProposalData.DsProposalData.Tables[0].Rows[0]["secondaryGoal"].ToString().Trim().Substring(i * 64, titleCount);
else
titleStrings[i] = objProposalData.DsProposalData.Tables[0].Rows[0]["secondaryGoal"].ToString().Trim().Substring(i * 64, 64);
}
//pdfTableRow myRow = myTable.createRow();
//myRow[0].columnAlign = predefinedAlignment.csCenter;
//if (i == (titleRows - 1))
//{
// myRow[0].columnValue = objProposalData.DsProposalData.Tables[0].Rows[0]["secondaryGoal"].ToString().Substring(i * 64, titleCount - ((i * 64) + 2));
//}
//else
//{
// if (i == 0 & titleCount <= 64)
// {
// myRow[0].columnValue = objProposalData.DsProposalData.Tables[0].Rows[0]["secondaryGoal"].ToString().Trim().Substring(i * 64, titleCount);
// }
// else
// {
// myRow[0].columnValue = objProposalData.DsProposalData.Tables[0].Rows[0]["secondaryGoal"].ToString().Trim().Substring(i * 64, 64);
// }
//}
//myTable.addRow(myRow);
}
foreach (string newString in titleStrings)
{
pdfTableRow myRow = myTable.createRow();
myRow[0].columnAlign = predefinedAlignment.csCenter;
myRow[0].columnValue = newString.Trim();
myTable.addRow(myRow);
myRow = null;
}

myPage.addTable(myTable, 21, 771);
myTable = null;

Please any one tell me why the error is occuring.

Page 1 of 1 All times are UTC
Powered by phpBB® Forum Software © phpBB Group
https://www.phpbb.com/