PDFsharp & MigraDoc Foundation

PDFsharp - A .NET library for processing PDF & MigraDoc Foundation - Creating documents on the fly
It is currently Thu Nov 14, 2019 9:19 am

All times are UTC


Forum rules


Please read this before posting on this forum: Forum Rules



Post new topic Reply to topic  [ 70 posts ]  Go to page 1, 2  Next
Author Message
PostPosted: Tue Mar 17, 2009 1:49 pm 
Offline

Joined: Tue Mar 17, 2009 1:43 pm
Posts: 1
Hello

First of all, thank you for this excellent piece of software.

I see in your announcement, that MigraDoc is very slow when rendering large tables.

I am generating large tables (with 10.000 or more rows) which means about 400 pages. It takes about 10 minutes to generate.

You wrote that you will be fixing this slow rendering, but do you have any idea of when?

Thank you


Top
 Profile  
Reply with quote  
PostPosted: Wed Nov 03, 2010 9:26 am 
Offline

Joined: Wed Nov 03, 2010 9:23 am
Posts: 1
This post was not replied for quite a long time. I have same problem, slow rendering of tables.

Can you give roughly term of solving that issue?

It has been almost year from last version release so I'm really looking forward next relese with this issue fixed :)

Regards


Top
 Profile  
Reply with quote  
PostPosted: Wed Jan 19, 2011 5:38 am 
Offline

Joined: Wed Jan 19, 2011 5:34 am
Posts: 19
I patched sources to speed up table rendering, it became 2 - 3 times faster (probably even better on bigger tables).
Can share the patch if you want.


Top
 Profile  
Reply with quote  
PostPosted: Wed Jan 19, 2011 2:42 pm 
Offline

Joined: Fri Oct 24, 2008 12:24 pm
Posts: 13
Location: Brisbane, Australia
@ pakeha_by

Please share the patch - I am sure this would be of interest to many people


Top
 Profile  
Reply with quote  
PostPosted: Thu Jan 20, 2011 3:31 pm 
Offline
Supporter
User avatar

Joined: Thu May 27, 2010 7:40 pm
Posts: 59
Location: New Hampshire, USA
I found that when rendering paragraph content within a table cell, the XFonts are not cached and there seems to be a huge amount of time spent creating fonts in order to measure text heights/widths, etc to see whether a given word fits in the area or not.

Another thing that seriously slowed down table rendering was the use of reflection to get the row/column information of a cell. Caching the cell's row/column info after fetching it the first time made a huge difference as I recall also... Generally speaking the use of reflection is what is causing a majority of the slowdowns. The reflection (Meta) code is clever and helps simplify MDDL loading some, but seems to really hurt performance for those who are generating very large or huge numbers of documents. From an interactive standpoint, its not too bad, but I wonder if that many people are using this library for writing interactive PDF editors vs converters or alternate output formats for some other application.

I would also be interested in the techniques you used to speed up table rendering, so please post a zip if you can of your new code. :)


Top
 Profile  
Reply with quote  
PostPosted: Wed Mar 23, 2011 8:58 am 
Offline

Joined: Wed Jan 19, 2011 5:34 am
Posts: 19
Sorry guys, I didn't receive notifications from this thread.

Patch is attached to this post, source codes are availalbe at https://pdfsharp.svn.codeplex.com/svn/MigraDoc/code

If somebody will use this patch please let me know what's the performance inprovement in your case.


Attachments:
TableRenderPatch.zip [7.2 KiB]
Downloaded 97166 times
Top
 Profile  
Reply with quote  
PostPosted: Thu Mar 24, 2011 11:30 am 
Offline

Joined: Thu Mar 24, 2011 11:19 am
Posts: 2
How can I aply this patch to my Sources?


Top
 Profile  
Reply with quote  
PostPosted: Thu Mar 24, 2011 9:18 pm 
Offline

Joined: Wed Jan 19, 2011 5:34 am
Posts: 19
Here is new version of the patch, there was a bug in rendering of vertically merged cells in some circumstances.

To apply patch use TortoiseSVN command "Apply Patch..." or use external tool http://gnuwin32.sourceforge.net/downlinks/patch-bin-zip.php: patch.exe -p0 < TableRendering.patch


Attachments:
TableRendering.zip [7.21 KiB]
Downloaded 96471 times
Top
 Profile  
Reply with quote  
PostPosted: Tue Mar 29, 2011 6:35 pm 
Offline

Joined: Thu Nov 26, 2009 6:00 am
Posts: 2
With this fix the Rendering is very fast and Thanks to the PDFSharp and Migradoc Team :-)

Without the fix it took more than 5 minutes to render a 40+ pages document with approximately 5000 rows of data. After the fix it is now taking only a maximum of 12 seconds :-)


Top
 Profile  
Reply with quote  
PostPosted: Tue Mar 29, 2011 9:36 pm 
Offline

Joined: Wed Jan 19, 2011 5:34 am
Posts: 19
I'm not PDFSharp team member, just regular library user. :)

Thank you for feedback, may be it will speed up process to include patch to release


Top
 Profile  
Reply with quote  
PostPosted: Mon Apr 04, 2011 7:35 pm 
Offline

Joined: Thu Mar 31, 2011 9:49 pm
Posts: 2
Great! Thanks for sharing pakeha_by!


Top
 Profile  
Reply with quote  
PostPosted: Tue Apr 12, 2011 8:40 pm 
Offline

Joined: Fri Feb 26, 2010 3:50 pm
Posts: 4
Do you think its possible to post the updated library/dll or even repackage the update into the current release/installer?

It would be great if the team could check the code and roll it into an updated release (given the huge performance improvement), that would make it much easier for those unfamiliar with SVN or recompiling libraries etc...

Thanks, TJ.


Top
 Profile  
Reply with quote  
PostPosted: Fri Apr 15, 2011 9:18 am 
Offline

Joined: Fri Apr 15, 2011 9:02 am
Posts: 1
@pakeha_by: Thank you very much for this patch!

I noticed that you submitted the patch to migradoc.codeplex.com, but it seems to me that pdfsharp.codeplex.com is the official home for both PDFsharp and MigraDoc. Maybe you want to consider submitting the patch at the PDFsharp CodePlex site as well...

Thanks again, I hope this patch will be included in the official release soon.


Top
 Profile  
Reply with quote  
PostPosted: Sun Apr 17, 2011 12:24 pm 
Offline

Joined: Wed Jan 19, 2011 5:34 am
Posts: 19
@roelvandersteen

Both sites (migradoc.codeplex.com and pdfsharp.codeplex.com) are managed by same people so it doesn't really matter where to upload patch. But thank you for the tip, I uploaded final version of the patch to migradoc.codeplex.com for consistency.


Top
 Profile  
Reply with quote  
PostPosted: Thu Jul 21, 2011 9:23 am 
Offline

Joined: Mon Jun 27, 2011 1:59 pm
Posts: 2
Thanks for the patch! Was afraid i had to do it myself - very happy i didn't need to :-)
Performance was boosted by factor >10 in my case!


Top
 Profile  
Reply with quote  
PostPosted: Fri Aug 12, 2011 8:16 am 
Offline

Joined: Fri Aug 12, 2011 7:55 am
Posts: 2
Hi guys,

I want to patch, but I don't know how to. :oops:

Can someone explain me, step by step how to apply this patch ? :roll:

or better for me give a link to the patched dll ?

Thanks

regards,

PFa38


Top
 Profile  
Reply with quote  
PostPosted: Fri Aug 12, 2011 12:35 pm 
Offline

Joined: Wed Jan 19, 2011 5:34 am
Posts: 19
Here is compiled assemblies with applied patch: http://www.pakeha_by.my-webs.org/MigraDocFastTableRender.html

As I asked earlier in this thread, please let me know how faster it become.

Cheers


Top
 Profile  
Reply with quote  
PostPosted: Fri Aug 12, 2011 1:51 pm 
Offline

Joined: Fri Aug 12, 2011 7:55 am
Posts: 2
Awesome !

2 minutes -> 9 seconds.

for a 5 pages document.
In each page an array (approx 70 cols and 35 row) of small arrays (1 row an 1 col) in 30% of cells

Thanks ! :D


Top
 Profile  
Reply with quote  
PostPosted: Fri Aug 26, 2011 2:04 pm 
Offline

Joined: Fri Aug 26, 2011 2:00 pm
Posts: 1
Many, many thanks for this patch. I cannot give an exact figure for performance improvement because my rendering wasn't finishing. Now, it finishes a complex, 800 row table in under 2 minutes on a single core of my Core2 developer box.


Top
 Profile  
Reply with quote  
PostPosted: Fri Sep 23, 2011 4:45 pm 
Offline

Joined: Thu Jul 16, 2009 2:38 pm
Posts: 16
After apply this patch the render of table is very fast. But there is a problem.

After applying the patch you no longer have the ability to hide the border rows
For example the following code no longer works

Code:
           
Dim t As New Table
Dim r As Row
For index As Integer = 1 To 100
r = t.AddRow
r.Borders.Bottom.Visible = (index Mod 2 = 0)
Next


thanks,
Valeriano


Top
 Profile  
Reply with quote  
PostPosted: Mon Sep 26, 2011 3:41 am 
Offline

Joined: Wed Jan 19, 2011 5:34 am
Posts: 19
Valeriano,

could you please clarify what doesn't work in your case - what is expected/old result and what's new outcome after patch?
If you want to hide borders between odd and event rows you also need hide TOP border of neighbor from bottom:

Code:
     
for (int index = 0; index < 100; index++) {
        Row row = table.AddRow();
        row.Cells[0].AddParagraph("This is row");
        row.Borders.Bottom.Visible = (index % 2 == 0);
        row.Borders.Top.Visible = (index % 2 == 1);
      }


Top
 Profile  
Reply with quote  
PostPosted: Mon Sep 26, 2011 11:35 am 
Offline

Joined: Thu Jul 16, 2009 2:38 pm
Posts: 16
Hi,

before the patch was hiding at the bottom border of the row simply with

Code:
row.Borders.Bottom.Visible = False


after the patch I had to use the solution proposed by you.

Now it works.

thanks,
Valeriano


Top
 Profile  
Reply with quote  
PostPosted: Tue Oct 18, 2011 4:45 pm 
Offline

Joined: Tue Oct 18, 2011 4:35 pm
Posts: 1
Well Done!!! I received incredible speed increase in my usage.
Previously a 40x30 grid of 6 pages took 112 seconds to render, but now it takes only 7 seconds.
4 pages were 78 seconds and now it takes 4 seconds.
Congratulations on a job well done, and Thank you!
:mrgreen:


Top
 Profile  
Reply with quote  
PostPosted: Tue May 22, 2012 2:02 am 
Offline

Joined: Thu May 10, 2012 11:52 pm
Posts: 7
1200 rows/3 columns
got down to 2 seconds from 120 seconds. Thanks A LOT!


Top
 Profile  
Reply with quote  
PostPosted: Sat Sep 15, 2012 9:39 am 
Offline
User avatar

Joined: Sat Sep 15, 2012 7:47 am
Posts: 5
Hello everyone, we are glad and thankful for the patch, its really faster.

There is one problem. When you have some scenario with merged right cells the borders don't work properly

To be more specific. When you have let's say a table with 6 columns and you MergeRight 2 from from index 0 and again MergeRight 2 from index 3 somehow the left margin gets copied to the right margin of the merged cell and it is drawn even though it should not. I was trying to debug the library, and found out, the right margin property is set even though it should not be. But I wasn't able find out where this exactly happens. I didn't want to give it too much time, before I ask here.

Here is the code:

Definition of the styles, I am sending just the relevant part:

Code:
bgColor = new Color(234, 237, 245);
tableEdgeType = Edge.Left;
tableEdgeStyle = MigraDoc.DocumentObjectModel.BorderStyle.Single;
tableEdgeWidth = 0.5;
itemRowBorder.Width = 0.5;
itemRowBorder.Style = MigraDoc.DocumentObjectModel.BorderStyle.Dot;
style = this.Document.Styles.AddStyle("Table", "Classic");
style.Font.Size = 12;
style.ParagraphFormat.SpaceBefore = 1;
style.ParagraphFormat.SpaceAfter = 1;
style.ParagraphFormat.LeftIndent = 1;
style = this.Document.Styles.AddStyle("Text", "Classic");
style.Font.Name = "Tahoma";
style.Font.Size = 12;
style = this.Document.Styles.AddStyle("TextTitle", "Text"); //text title e.g. "Faktura"
style.Font.Size = 20;
style.Font.Bold = true;
style.ParagraphFormat.SpaceBefore = 0;

//define styles for All tables in invoice except item and summary table
style = this.Document.Styles.AddStyle("TableRowAll", "Table");
style.Font.Size = 10;
style = this.Document.Styles.AddStyle("TableRowAllLarge", "Table");
style.Font.Size = 12;
style = this.Document.Styles.AddStyle("TableRowAllSmall", "Table");
style.Font.Size = 8;


and here is the code that creates table itself:

Code:
Table table = section.AddTable();
table.Style = "TableRowAll";

// Left side of the table
Column column = table.AddColumn("2.69cm");
column = table.AddColumn("3.8cm");
column = table.AddColumn("2.49cm");

// right side of the table
column = table.AddColumn("2.69cm");
column = table.AddColumn("3.8cm");
column = table.AddColumn("2.49cm");

// Left part of the header
Row row = table.AddRow();
row.Cells[0].MergeRight = 2;
row.Cells[0].AddParagraph(ReportResources.InvoiceDodavatel.ToUpper() + ":");
row.Cells[0].Shading.Color = bgColor;

//*****************************
// problem here!
row.Cells[0].Borders.Left.Style = tableEdgeStyle;
row.Cells[0].Borders.Left.Width = tableEdgeWidth;
// it should draw just the left margin, but it draws right margin as well
//*****************************

// Right part of the header
row.Cells[3].MergeRight = 2;
row.Cells[3].AddParagraph(ReportResources.InvoiceOdberatel.ToUpper() + ":");
row.Cells[3].Shading.Color = bgColor;


Image

Thanks for help,

Michal


Top
 Profile  
Reply with quote  
PostPosted: Mon Sep 17, 2012 8:11 am 
Offline
PDFsharp Guru
User avatar

Joined: Mon Oct 16, 2006 8:16 am
Posts: 2998
Location: Cologne, Germany
Hi, Michal!
putenec wrote:
I didn't want to give it too much time, before I ask here.
I presume the error occurs only with the patched version, not the original version?

_________________
Regards
Thomas Hoevel
PDFsharp Team


Top
 Profile  
Reply with quote  
PostPosted: Mon Sep 17, 2012 9:09 am 
Offline

Joined: Wed Jan 19, 2011 5:34 am
Posts: 19
Hi Michal

There is a bug in patched version - when it calculates border width it does not take into consideration cell merging.

MergedCellList.GetNeighbor() function should look like that:
Code:
    private Cell GetNeighbor(CellInfo cellInfo, NeighborPosition position)
    {
      var cell = cellInfo.Cell;

      switch (position) {
        case NeighborPosition.Left:
          if (cellInfo.BlockCol > 0)
            return CellInfos[cellInfo.BlockRow, cellInfo.BlockCol - 1].Cell;
          break;

        case NeighborPosition.Right:
          if (cellInfo.BlockCol + cell.MergeRight < ColCount - 1)
           return CellInfos[cellInfo.BlockRow, cellInfo.BlockCol + cell.MergeRight + 1].Cell;
          break;

        case NeighborPosition.Top:
          if (cellInfo.BlockRow > 0)
            return CellInfos[cellInfo.BlockRow - 1, cellInfo.BlockCol].Cell;
          break;

        case NeighborPosition.Bottom:
          if (cellInfo.BlockRow + cell.MergeDown < RowCount - 1)
           return CellInfos[cellInfo.BlockRow + cell.MergeDown + 1, cellInfo.BlockCol].Cell;
          break;
      }



If you are using pre-built assemblies then let me know, I'll create new version of them.

Andrew


Top
 Profile  
Reply with quote  
PostPosted: Tue Sep 18, 2012 10:25 am 
Offline
User avatar

Joined: Sat Sep 15, 2012 7:47 am
Posts: 5
Dear Andrew,

thank you for the fix. For what I have tried so far, it works fine. I am surprised this issue has not been addressed earlier.
If I find something in the future, I will let you know.

Best regards,

Michal

Image


Top
 Profile  
Reply with quote  
PostPosted: Tue Sep 18, 2012 10:33 am 
Offline
User avatar

Joined: Sat Sep 15, 2012 7:47 am
Posts: 5
Thomas Hoevel wrote:
Hi, Michal!
putenec wrote:
I didn't want to give it too much time, before I ask here.
I presume the error occurs only with the patched version, not the original version?


Hello Thomas,

the original version works fine, doesn't have this problem. But as it has been mentioned here, it is very slow while working with tables. Do you consider to upgrade the libraries with this improvement in the future?

Best regards,

Michal


Top
 Profile  
Reply with quote  
PostPosted: Tue Sep 18, 2012 10:51 am 
Offline
PDFsharp Guru
User avatar

Joined: Mon Oct 16, 2006 8:16 am
Posts: 2998
Location: Cologne, Germany
We know that table rendering is slow, very slow.
We will make it faster.

But we will verify that tables rendered with the new, faster code will look the same as tables rendered with the old, slow "reference implementation".

_________________
Regards
Thomas Hoevel
PDFsharp Team


Top
 Profile  
Reply with quote  
PostPosted: Wed Sep 19, 2012 5:50 pm 
Offline
User avatar

Joined: Sat Sep 15, 2012 7:47 am
Posts: 5
Hello guys,

If we use the same code as in my first post for the definition of styles and change line number two from tableEdgeType = Edge.Left; to tableEdgeType = Edge.Box; and then we want to use SetEdge method to draw the edge:

Code:
Table table = section.AddTable();
table.Style = "TableRowAll";

// Left side of the table
Column column = table.AddColumn("2.7cm");
column = table.AddColumn("3.8cm");
column = table.AddColumn("2.5cm");

// right side of the table
column = table.AddColumn("2.7cm");
column = table.AddColumn("3.8cm");
column = table.AddColumn("2.5cm");//column for logo

// Left part of the header
Row row = table.AddRow();
row.Cells[0].MergeRight = 2;
row.Cells[0].AddParagraph(ReportResources.InvoiceDodavatel.ToUpper() + ":");
row.Cells[0].Shading.Color = bgColor;
//row.Cells[0].Borders.Style = tableEdgeStyle;
//row.Cells[0].Borders.Width = tableEdgeWidth;

// Right part of the header
row.Cells[3].MergeRight = 2;
row.Cells[3].AddParagraph(ReportResources.InvoiceOdberatel.ToUpper() + ":");
row.Cells[3].Shading.Color = bgColor;

//*******************
// problematic part
table.SetEdge(0, 0, 2, table.Rows.Count, tableEdgeType, tableEdgeStyle, tableEdgeWidth);
//*******************


Here is what happens:

Image

If you draw it manually, uncomment these two lines
Code:
row.Cells[0].Borders.Style = tableEdgeStyle;
row.Cells[0].Borders.Width = tableEdgeWidth;


and comment out the SetEdge line, it draws it correctly.

Image

Thanks,

Michal


Top
 Profile  
Reply with quote  
PostPosted: Wed Sep 19, 2012 10:00 pm 
Offline

Joined: Wed Jan 19, 2011 5:34 am
Posts: 19
Hi Michal
putenec wrote:
I am surprised this issue has not been addressed earlier.

I assume very few people uses patched version and even fewer has got complex borders/styling - you were first one who met this problem.

Code:
//*******************
// problematic part
table.SetEdge(0, 0, 2, table.Rows.Count, tableEdgeType, tableEdgeStyle, tableEdgeWidth);
//*******************

Please note that column 1 has got MergedRight = 2 so merged cell is 3-columns wide and right edge of your .setEdge is coming through it.

If you call table.SetEdge(0, 0, 3, ... then everything is OK.


Andrew


Top
 Profile  
Reply with quote  
PostPosted: Thu Sep 20, 2012 11:09 am 
Offline

Joined: Thu Sep 20, 2012 10:57 am
Posts: 1
Thomas Hoevel wrote:
We know that table rendering is slow, very slow.
We will make it faster.

But we will verify that tables rendered with the new, faster code will look the same as tables rendered with the old, slow "reference implementation".


Hi Thomas.

Do you have an idea of ​​when you are ready with a "faster rendering" version?
Regards Anders


Top
 Profile  
Reply with quote  
PostPosted: Fri Sep 21, 2012 12:46 pm 
Offline
User avatar

Joined: Sat Sep 15, 2012 7:47 am
Posts: 5
anders wrote:
Thomas Hoevel wrote:
We know that table rendering is slow, very slow.
We will make it faster.

But we will verify that tables rendered with the new, faster code will look the same as tables rendered with the old, slow "reference implementation".


Hi Thomas.

Do you have an idea of ​​when you are ready with a "faster rendering" version?
Regards Anders


I would suggest for you to take the latest version of the patch, you can patch files easily with the patch.exe, using command prompt, just copy everything into one folder. For example:

1. Create C:\migra
2. Download: http://gnuwin32.sourceforge.net/downlin ... in-zip.php into C:\migra
3. Extract the patch-2.5.9-7-bin.zip
4. Go to C:\migra\bin
5. Copy the following folders including subfolders from your MigraDoc library:
MigraDoc.DocumentObjectModel
MigraDoc.Rendering
6. the content of your C:\migra\bin folder should look like this:
patch.exe
TableRendering.patch
MigraDoc.DocumentObjectModel
MigraDoc.Rendering
7. run cmd and cd into C:\migra\bin
8. run patch.exe -p0 < TableRendering.patch

After this procedure copy the two patched MigraDoc folders back into your project.

Read post from Andrew, where he talks about fixing one method called GetNeighbor. Verify whether the correct code is inside, if not replace the code manually.

Build your project and use fast table rendering.

Michal


Top
 Profile  
Reply with quote  
PostPosted: Fri Sep 21, 2012 10:48 pm 
Offline

Joined: Wed Jan 19, 2011 5:34 am
Posts: 19
In case somebody needs compiled assemblies, I've uploaded patched 1.32 assemblies and patch itself to the site http://pakeha_by.my-webs.org/MigraDocFastTableRender.html. It also includes above fix for borders between merged cells.


Top
 Profile  
Reply with quote  
PostPosted: Wed Sep 26, 2012 4:29 pm 
Offline

Joined: Wed Sep 26, 2012 4:26 pm
Posts: 1
Hi pakeha_by,
Can you upload assemblies compiled in Release mode? The Pdf files generated by the debug mode assemblies are much larger.
Thanks


Top
 Profile  
Reply with quote  
PostPosted: Thu Sep 27, 2012 10:46 am 
Offline

Joined: Wed Jan 19, 2011 5:34 am
Posts: 19
mompox wrote:
Hi pakeha_by,
Can you upload assemblies compiled in Release mode? The Pdf files generated by the debug mode assemblies are much larger.
Thanks


No problem, I've added Release assemblies to the site as well.

Cheers


Top
 Profile  
Reply with quote  
PostPosted: Thu Feb 21, 2013 2:26 pm 
Offline

Joined: Thu Feb 21, 2013 2:21 pm
Posts: 1
Hi pakeha_by,

i tried today your patch and my rendering went from 50 seconds to 9-10 seconds.. Thank you for your work!!

The table looks like the old one (but faster) and everything else seemed to be perfect too..

Thank you again!


Top
 Profile  
Reply with quote  
PostPosted: Wed Apr 17, 2013 2:04 am 
Offline

Joined: Tue Apr 16, 2013 7:37 pm
Posts: 1
Andrew (pakeha_by) -

Thank you so much for your remarkable contribution. My render times went from the 8 to 10 minute range to about 15-20 seconds. This is for tables that end up spanning about 100 pages. Previously I was having trouble even getting the rendering to complete on smaller cloud instances, based upon the resources available. This is a huge improvement, and I have studied my results and can find no visible difference in the resulting tables being rendered. For whatever reason patch.exe would just give me a blank screen when run from the command line with the correct parameters, but I was able to successfully patch using TortoiseSVN and the patch file. It's disappointing that it has been two years since you've shared this significant contribution and even submitted it back for an upcoming release, yet it's still not part of the current release. In the absence of progress with the open source project, I'd encourage others to try this patch and hopefully someday it will be a part of the official release.


Top
 Profile  
Reply with quote  
PostPosted: Wed Apr 17, 2013 8:37 am 
Offline
PDFsharp Guru
User avatar

Joined: Mon Oct 16, 2006 8:16 am
Posts: 2998
Location: Cologne, Germany
andy_f wrote:
It's disappointing that it has been two years since you've shared this significant contribution and even submitted it back for an upcoming release, yet it's still not part of the current release.
Nice that it works for you, but it is not fully compatible to the original implementation.
See here:
viewtopic.php?p=6852#p6852

We need an implementation that is 100% compatible.

_________________
Regards
Thomas Hoevel
PDFsharp Team


Top
 Profile  
Reply with quote  
PostPosted: Tue Oct 29, 2013 5:30 pm 
Offline

Joined: Tue May 19, 2009 2:37 pm
Posts: 8
Now that KeepWith is fixed in pakeha patch (see http://forum.pdfsharp.net/viewtopic.php?p=6852#p7408)... do you think it is time to add it to the official release?

Or there are other issues with the patch?

I think it would be great to add this to the official release, to be added via Nuget and not requiring repatching in new official releases.

Thanks!!


Top
 Profile  
Reply with quote  
PostPosted: Wed Oct 30, 2013 9:17 am 
Offline
PDFsharp Guru
User avatar

Joined: Mon Oct 16, 2006 8:16 am
Posts: 2998
Location: Cologne, Germany
romias wrote:
Now that KeepWith is fixed in pakeha patch do you think it is time to add it to the official release?
We need an implementation that is 100% compatible.
There was a problem with borders, there was a problem with KeepWith, there may be other problems. It won't be included without extensive QA. I am not the person to make that decision.

_________________
Regards
Thomas Hoevel
PDFsharp Team


Top
 Profile  
Reply with quote  
PostPosted: Tue Feb 18, 2014 4:16 pm 
Offline

Joined: Tue Feb 18, 2014 4:03 pm
Posts: 1
Hi

I have found a bug.
If I make a cell which is 2 rows high (MergeDown=1) and the text has more than 2 lines, the text goes outside the cell.
In 2 cells right to the big cell I had texts with 1 line each.

It would be great if somebody could fix it :)

Pawel


Top
 Profile  
Reply with quote  
PostPosted: Fri Sep 26, 2014 1:36 pm 
Offline

Joined: Mon May 12, 2014 6:06 pm
Posts: 8
izaurek wrote:
Hi

I have found a bug.
If I make a cell which is 2 rows high (MergeDown=1) and the text has more than 2 lines, the text goes outside the cell.
In 2 cells right to the big cell I had texts with 1 line each.

It would be great if somebody could fix it :)

Pawel

I implemented the code and found this to be the case as well. I am not sure why. I'm very frustrated with the slow table rendering. I have to create a PDF that occasionally requires upwards of 50,000 rows (over about 315 pages). It took 2-3 hours to generate the file, which is just too long.

It took about 35 seconds with the new patch, but then it messes up my formatting on cells that are merged down :(.


Top
 Profile  
Reply with quote  
PostPosted: Thu Oct 02, 2014 11:42 am 
Offline

Joined: Wed Jan 19, 2011 5:34 am
Posts: 19
In case somebody still need fix for problem mentioned above (MergeDown = 1 with multiple lines):

File TableRenderer.cs, method TableRenderer.CreateNextBottomBorderPosition(), line 601:

instead of
Code:
foreach (Cell cell in this.mergedCells.GetCells(Math.Max(0, lastBorderRow), minMergedCell.Row.Index + minMergedCell.MergeDown))


must be (edited, I realize that previous fix won't work in some more complex circumstances)

Code:
      foreach (Cell cell in this.mergedCells.GetCells(Math.Max(0, this.mergedCells.GetFirstRowMergedWithRow(lastBorderRow))), minMergedCell.Row.Index + minMergedCell.MergeDown))


and add method GetFirstRowMergedWithRow() to MergedCellList class:

Code:
    public int GetFirstRowMergedWithRow(int row)
    {
        if (row == 0 || row >= this.RowCount)
            return row;

        var result = row;

        for (int colIndex = 0; colIndex < ColCount; colIndex++)
        {
            CellInfo cellInfo = CellInfos[row, colIndex];
            result = Math.Min(result, cellInfo.BlockRow);
            colIndex += cellInfo.Cell.MergeRight;
        }

        return result;
    }



Last edited by pakeha_by on Thu Oct 02, 2014 10:47 pm, edited 1 time in total.

Top
 Profile  
Reply with quote  
PostPosted: Thu Oct 02, 2014 5:32 pm 
Offline

Joined: Mon May 12, 2014 6:06 pm
Posts: 8
pakeha_by wrote:
In case somebody still need fix for problem mentioned above (MergeDown = 1 with multiple lines):

File TableRenderer.cs, method TableRenderer.CreateNextBottomBorderPosition(), line 601:

instead of
Code:
foreach (Cell cell in this.mergedCells.GetCells(Math.Max(0, lastBorderRow), minMergedCell.Row.Index + minMergedCell.MergeDown))


must be

Code:
      int startFromRow = lastBorderRow;
      while (startFromRow > 0 && (int)this.connectedRowsMap.GetByIndex(startFromRow - 1) == (int)this.connectedRowsMap.GetByIndex(lastBorderRow))
          startFromRow--;

      foreach (Cell cell in this.mergedCells.GetCells(Math.Max(0, startFromRow), minMergedCell.Row.Index + minMergedCell.MergeDown))


I can confirm that this last bit of code fixes any problems I've encountered thus far. My tables are rendering like lighting now :).

There is one caveat, which I am working on fixing.
If you change the borders of a cell during render time, after the MergedCellList.CellIndex has been populated, then the changes won't be rendered.
The "issue" (and I use the term lightly, because it is NOT an issue unless you are trying to change how tables render) stems from the MergedCellList.GetEffectiveBorders method.

The only reason I discovered this is due to my need to render a custom border on the last table row on each page. I can successfully update the cell borders, but when the cell is rendered it pulls border information.

I am currently overriding the Equals method for both the Borders and Border object, which will allow me to compare Borders information from CellInfo.Borders and Cell.Borders for equality. In the event they are not equal, the data from Cell.Borders can be copied over to CellInfo.Borders.

Well, that's the thought, anyway. :(


Top
 Profile  
Reply with quote  
PostPosted: Tue Oct 28, 2014 3:31 am 
Offline

Joined: Tue Oct 28, 2014 2:52 am
Posts: 7
I have applied the fixes provided by Pekeha_by, as well as the latest code change he supplied to fix the "KeepWith" issue. The speed improvement is beyond dramatic! Thank you so much for putting this together for us.

I did come across one area where it appears that your code has limitations, so I thought I would share. I noticed that the code you supplied does not appear to work with styles. The result is an empty area.

This code does not work:
Code:
//make style to reference
Style style = document.Styles.AddStyle("Summary", "Normal");
style.Font.Size = 12;
style.ParagraphFormat.Shading.Color = colorGreen;

//create a paragraph of the above style
paragraph = section.AddParagraph();

paragraph.Style = "Summary";
paragraph.AddText("A bunch of text goes here n stuff");

I get a blank, colored box. However, no text appears inside of it.


Whereas this code would work:
Code:
//create a paragraph
paragraph = section.AddParagraph();

paragraph.Format.Font.Size = 12;
paragraph.Format.Shading.Color = colorGreen;
paragraph.AddText("A bunch of text goes here n stuff");

The text appears within the colored box as anticipated.


I don't know enough to claim that my code is 100% correct, but I do know the original (top) code was working with the official 1.32 assemblies. When I switched over to the Pekeha_by code (most recent), it stopped working as expected. The text throughout my documents basically disappeared.

I know this issue will have to be resolved in order for the code to be included in the next release of MigraDoc. As for myself, I am going through my code and removing all style references as we speak so that I can have correct rendering AND the blazing speed! This is working for me, so I hope this helps someone else.


Top
 Profile  
Reply with quote  
PostPosted: Tue Oct 28, 2014 8:49 pm 
Offline

Joined: Wed Jan 19, 2011 5:34 am
Posts: 19
yellowmosquito wrote:
This code does not work:



Works fine for me (see attachment):
Code:
            //make style to reference
            Style style = document.Styles.AddStyle("Summary", "Normal");
            style.Font.Size = 12;
            style.ParagraphFormat.Shading.Color = new Color(0, 255, 0);

            var section = document.AddSection();

            //create a paragraph of the above style
            var paragraph = section.AddParagraph();

            paragraph.Style = "Summary";
            paragraph.AddText("A bunch of green text goes here n stuff");

            paragraph = section.AddParagraph();
            paragraph.AddText("A bunch of regular text goes here n stuff");



Attachments:
para.png
para.png [ 6.73 KiB | Viewed 6123650 times ]
Top
 Profile  
Reply with quote  
PostPosted: Wed Oct 29, 2014 8:40 am 
Offline
PDFsharp Guru
User avatar

Joined: Mon Oct 16, 2006 8:16 am
Posts: 2998
Location: Cologne, Germany
pakeha_by wrote:
Works fine for me
Your paragraphs are not in a table. Does it still work with a table around the paragraphs?

_________________
Regards
Thomas Hoevel
PDFsharp Team


Top
 Profile  
Reply with quote  
PostPosted: Wed Oct 29, 2014 9:19 am 
Offline

Joined: Wed Jan 19, 2011 5:34 am
Posts: 19
Thomas Hoevel wrote:
Your paragraphs are not in a table. Does it still work with a table around the paragraphs?


Yep
Code:
            var section = document.AddSection();
            var table = section.AddTable();

            var col = table.AddColumn();
            var row = table.AddRow();
            var cell = row.Cells[0];
            cell.Borders.Style = BorderStyle.Single;

            //create a paragraph of the above style
            var paragraph = cell.AddParagraph();

            paragraph.Style = "Summary";
            paragraph.AddText("A bunch of green text goes here");

            paragraph = cell.AddParagraph();
            paragraph.AddText("A bunch of regular text goes here");


Attachments:
style2.png
style2.png [ 6.45 KiB | Viewed 6123634 times ]
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 70 posts ]  Go to page 1, 2  Next

All times are UTC


Who is online

Users browsing this forum: No registered users and 11 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:  
Privacy Policy, Data Protection Declaration, Impressum
Powered by phpBB® Forum Software © phpBB Group