I am using a table to display legend data. The page is in landscape mode. I would like to limit the table rows to 15 per column. 2 columns per page and then a new page is created, and so on.
https://drive.google.com/file/d/0B6EfxKw0RE9DNlByamRENkVyM0E/view?usp=sharingCode:
//Create an Empty Page
PdfPage pdfpage = outputDocument.AddPage();
pdfpage.Size = PageSize.Letter; // Change the Page Size
pdfpage.Orientation = PageOrientation.Landscape;// Change the orientation property
//Get an XGraphics object for drawing
XGraphics xGrap = XGraphics.FromPdfPage(pdfpage);
//Create Fonts
XFont titlefont = new XFont("Calibri", 20, XFontStyle.Regular);
XFont tableheader = new XFont("Calibri", 15, XFontStyle.Bold);
XFont bodyfont = new XFont("Calibri", 11, XFontStyle.Regular);
//Draw the text
//double x = 250;
double y = 50;
//Title Binding
XTextFormatter textformater = new XTextFormatter(xGrap); //Used to Hold the Custom text Area
foreach (var item in data)
{
string colorStr = item.Color;
Regex regex = new Regex(@"rgb\((?<r>\d{1,3}),(?<g>\d{1,3}),(?<b>\d{1,3})\)");
//regex.Match(colorStr.Replace(" ", ""));
Match match = regex.Match(colorStr.Replace(" ", ""));
if (match.Success)
{
int r = int.Parse(match.Groups["r"].Value);
int g = int.Parse(match.Groups["g"].Value);
int b = int.Parse(match.Groups["b"].Value);
y = y + 30;
XRect ColorVal = new XRect(85, y, 5, 5);
XRect NameVal = new XRect(100, y, 250, 25);
var brush = new XSolidBrush(XColor.FromArgb(r, g, b));
xGrap.DrawRectangle(brush, ColorVal);
textformater.DrawString(item.Name, bodyfont, XBrushes.Black, NameVal);
};
};