PDFsharp & MigraDoc Foundation

PDFsharp - A .NET library for processing PDF & MigraDoc Foundation - Creating documents on the fly
It is currently Thu Jul 18, 2024 3:26 am

All times are UTC


Forum rules


Please read this before posting on this forum: Forum Rules



Post new topic Reply to topic  [ 2 posts ] 
Author Message
PostPosted: Tue Jun 16, 2015 10:25 am 
Offline

Joined: Wed Oct 29, 2014 3:46 pm
Posts: 4
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);

                    };
                };


Top
 Profile  
Reply with quote  
PostPosted: Tue Jun 16, 2015 11:16 am 
Offline
PDFsharp Guru
User avatar

Joined: Mon Oct 16, 2006 8:16 am
Posts: 3101
Location: Cologne, Germany
Also discussed on SO:
http://stackoverflow.com/a/30866025/162529

_________________
Regards
Thomas Hoevel
PDFsharp Team


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

All times are UTC


Who is online

Users browsing this forum: Google [Bot] and 31 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Privacy Policy, Data Protection Declaration, Impressum
Powered by phpBB® Forum Software © phpBB Group