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

how to limit table rows per page
https://forum.pdfsharp.net/viewtopic.php?f=2&t=3132
Page 1 of 1

Author:  texas697 [ Tue Jun 16, 2015 10:25 am ]
Post subject:  how to limit table rows per page

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=sharing

Code:
//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);

                    };
                };

Author:  Thomas Hoevel [ Tue Jun 16, 2015 11:16 am ]
Post subject:  Re: how to limit table rows per page

Also discussed on SO:
http://stackoverflow.com/a/30866025/162529

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