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

Extraneous row - hit breakpoint 3 times, get 4 rows
https://forum.pdfsharp.net/viewtopic.php?f=2&t=1379
Page 1 of 1

Author:  kingboyk [ Tue Oct 19, 2010 11:49 am ]
Post subject:  Extraneous row - hit breakpoint 3 times, get 4 rows

Hi,

I have code like this:
Code:
                        int i = 0;

                        if (dateRanges.Any())
                        {
                            // Document:
                            section.AddParagraph();
                            section.AddParagraph("Audit trail by date").Format.Font.Bold = true;
                            section.AddParagraph();
                            var table = section.AddTable();
                            table.Style = "Table";
                            table.Borders.Width = 0.25;
                            var c = table.AddColumn();
                            c.Format.Alignment = ParagraphAlignment.Left;
                            c.Width = Unit.FromCentimeter(18);

                            // Audit trail by date report:
                            foreach (string daterange in dateRanges)
                            {
                                ....

                                // Construct document table rows:
                                var row = table.AddRow();
                                row.HeadingFormat = true;
                                row.Format.Font.Bold = true;
                                row[0].AddParagraph(daterange + " " + i); i++; ----- BREAKPOINT HERE

                                var row2 = table.AddRow();
                                Cell cell = row2[0];

The int i declaration is there just to debug this issue.

The problem is that although I loop through this 3 times I get 4 date range rows.

The PDF comes out like this:

Daterange string 0
Data

Daterange string 1
Daterange string 0
Data

Daterange string 2
Data

I hit the breakpoint 3 times. The final value of i is 2. But I have 4 rows containing a daterange string.

At my wits end on this and conclude it may be a bug in the library?

Can supply full code and generated PDF by PM but can't post in the open as the code belongs to my employer.

Any help would be much appreciated!

Steve

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