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

Fast table rendering in MigraDoc
https://forum.pdfsharp.net/viewtopic.php?f=2&t=679
Page 2 of 2

Author:  Thomas Hoevel [ Wed Oct 29, 2014 9:30 am ]
Post subject:  Re: Fast table rendering in MigraDoc

So yellowmosquito may have a bug outside the shown code snippet.

Author:  yellowmosquito [ Wed Oct 29, 2014 2:15 pm ]
Post subject:  Re: Fast table rendering in MigraDoc

I'm sorry that I wasn't able to reproduce the issue for you. I have created a test case to remedy that. It is just a simple WinForms application - click the button to see each approach and generate the PDF.

Download the solution here. (Sorry, it was too large to attach to this form due to the assemblies.)
http://www.filedropper.com/migradocbug001


I hope this isn't just something I was doing wrong from the beginning. However, this approach did work just fine with the regular MigraDoc 1.32 libraries, so I can't see how it can be true 1:1 functionality.

Attachments:
File comment: Application Sample
Application.png
Application.png [ 12.34 KiB | Viewed 9428 times ]
File comment: Screenshot-Works
Works.png
Works.png [ 3.2 KiB | Viewed 9428 times ]
File comment: Screenshot-DoesNotWork
DoesNotWork.png
DoesNotWork.png [ 1.04 KiB | Viewed 9428 times ]

Author:  centravanti [ Thu Oct 30, 2014 9:23 am ]
Post subject:  Re: Fast table rendering in MigraDoc

Hello,
First of all, thanks for the PDFSharp Creator for creating this PDF generator library. Btw, i had the slowness problem when generating tables with lots of rows as well.
I was trying to patch with pakeha's patch but looks like the website is down?
Does anybody have a copy of it? Appreciate it if someone could send me the patch for the table rendering.

Thanks!

Author:  yellowmosquito [ Thu Oct 30, 2014 12:00 pm ]
Post subject:  Re: Fast table rendering in MigraDoc

centravanti wrote:
Hello,
First of all, thanks for the PDFSharp Creator for creating this PDF generator library. Btw, i had the slowness problem when generating tables with lots of rows as well.
I was trying to patch with pakeha's patch but looks like the website is down?
Does anybody have a copy of it? Appreciate it if someone could send me the patch for the table rendering.

Thanks!


Centravanti,

Try again. The site is back up now. You probably just hit the maintenance window.

Author:  centravanti [ Fri Oct 31, 2014 9:19 am ]
Post subject:  Re: Fast table rendering in MigraDoc

yellowmosquito wrote:
Centravanti,

Try again. The site is back up now. You probably just hit the maintenance window.


You are right, I could get it now. Thanks!

Author:  andy-w [ Fri Oct 31, 2014 10:54 am ]
Post subject:  Re: Fast table rendering in MigraDoc

Wow, I have a large table 200+ pages and was taking over 15 minutes.

Applied this patch and now its around 30 seconds!!

Excellent patch. Is this ever going to make it into a real release I wonder.

:D

Author:  pakeha_by [ Thu Nov 13, 2014 7:38 pm ]
Post subject:  Re: Fast table rendering in MigraDoc

Hi all

Issue with styles is fixed.

Web page http://www.pakeha_by.my-webs.org/MigraDocFastTableRender.html updated with most recent patch (must be applied to original source code) and compiled assemblies. All fixed mentioned in this thread are included.

Cheers

Author:  centravanti [ Thu Dec 18, 2014 9:38 am ]
Post subject:  Re: Fast table rendering in MigraDoc

pakeha_by wrote:
Hi all

Issue with styles is fixed.

Web page http://www.pakeha_by.my-webs.org/MigraDocFastTableRender.html updated with most recent patch (must be applied to original source code) and compiled assemblies. All fixed mentioned in this thread are included.

Cheers


Hi Pakeha,
I tried to patch it, but i got these error message instead.

C:\Migra\bin>patch.exe -p0 < MigraDoc-1.32-TablePatch-r8.patch
patching file MigraDoc/code/MigraDoc.DocumentObjectModel/MigraDoc.DocumentObject
Model/Styles.cs
Assertion failed: hunk, file ../patch-2.5.9-src/patch.c, line 354

Author:  MaxOvrdrv [ Wed Mar 18, 2015 3:31 pm ]
Post subject:  Re: Fast table rendering in MigraDoc

hi,

Please help. I have installed the PDFSharp/MigraDoc package version 1.32 by using NuGet. How exactly do i go about updating / patching the NuGet package with your version of the libraries?

Whenever I simply replace the DLLs with your versions, my application stops running and I get multiple errors, which I am sure are not related to your DLLs but rather because I am trying to manually copy and replace the DLLs myself in the NuGet folder instead of updating/patching them?

If that's the case, can you please detail how I can update the NuGet DLLs myself or if there is a way of doing this through NuGet so that it doesn't freak out?

Thanks!

Author:  MaxOvrdrv [ Thu Mar 19, 2015 6:49 pm ]
Post subject:  Re: Fast table rendering in MigraDoc

WOW! What a difference! From 2 minutes to 3 seconds!!! Thank you so much!! :D

For those of you wondering how to do this if you got the Nuget package that included both PDFSharp and MigraDoc, here's what you do:
(in Visual Studio)
1- Uninstall the Nuget Package that you have installed
2- Grab the Release Assemblies from the provided link in this thread
3- Include the new assemblies (the ones you need) in your project
4- Reference them in your project
5- Note that the DLL files you include should be set to Content, Copy if Newer
6- Install the PDFSharp Nuget package ONLY, not the PDFSharp+MigraDoc

That's it... works really well for me like i said above. I had a table with 2700 rows, that used to take 2 minutes to render, and it now takes about 3 seconds!

Author:  pakeha_by [ Thu Mar 19, 2015 8:40 pm ]
Post subject:  Re: Fast table rendering in MigraDoc

MaxOvrdrv wrote:
For those of you wondering how to do this if you got the Nuget package that included both PDFSharp and MigraDoc...


Thanks for sharing your experience, I didn't use MigraDoc NuGet package so could not answer your question.

Author:  djenser [ Thu Apr 30, 2015 9:42 pm ]
Post subject:  Re: Fast table rendering in MigraDoc

In my project it did not work.

I downloaded the patched dll's and replaced the ones that were in my debug and release folder with the patched ones.
The time it takes to render a pdf file with a large table (this tables can be several pages long) is still 45 seconds tough.. the same as before.

What am i doing wrong?

1. I downloaded the Compiled assemblies v. 1.32 (Debug) and Compiled assemblies v. 1.32 (Release)
2. extracted the zip
3. Took MigraDoc.Rendering-WPF.dll, MigraDoc.DocumentObjectModel-WPF.dll and MigraDoc.RtfRendering-WPF.dl from the debug compiled assemblies and replaced the ones already present in the debug file
4. the same with the release file
5. clean solution/rebuilt solution
6. Run and same result

Author:  mr_Hilter [ Wed Sep 02, 2015 11:00 am ]
Post subject:  Re: Fast table rendering in MigraDoc

Thank you pakeha!

From 5 minutes, to less than 5 seconds!ยจ

I removed nuget package as stated before, imported references (make sure yo do not import regular and WPF files together, you will get an assembly reference error) and it works. The PDF files have exactly the same file size and I cannot spot a difference between the two. Thanks again pakeha!

Author:  TH-Soft [ Tue Sep 22, 2015 7:18 am ]
Post subject:  Re: Fast table rendering in MigraDoc

With PDFsharp 1.50 beta 2 (available on NuGet as a prerelease package), table rendering got much faster.

PDFsharp + MigraDoc WPF 1.32.2608:
Average: 24.443 seconds
MigraDoc-1.32-patched-release (WPF) from Pakeha:
Average: 9.114 seconds
PDFsharp + MigraDoc (WPF) 1.50.3638-beta:
Average: 16.114 seconds
PDFsharp + MigraDoc (WPF) 1.50.3915-beta2:
Average: 1.559 seconds

So maybe it is worth giving the new NuGet packages a try.
More details in this post:
viewtopic.php?p=9379#p9379

Author:  yellowmosquito [ Tue Sep 22, 2015 1:19 pm ]
Post subject:  Re: Fast table rendering in MigraDoc

Thank you for addressing this issue. The speed gains look very promising, and I would love to take advantage of them.

I've tried to bring the new files into my application today, but found several references missing (or perhaps just moved). Is there a good resource for finding where features within the code have been moved to?

(Specifically, I am having problems with code that was previously relying on PdfSharp.Forms.)

Thanks again for your work!

Author:  TH-Soft [ Tue Sep 22, 2015 1:48 pm ]
Post subject:  Re: Fast table rendering in MigraDoc

yellowmosquito wrote:
Specifically, I am having problems with code that was previously relying on PdfSharp.Forms.
You need a version with the GDI+ suffix.
See also:
http://pdfsharp.net/NuGetPackages.ashx

Author:  yellowmosquito [ Tue Sep 22, 2015 2:29 pm ]
Post subject:  Re: Fast table rendering in MigraDoc

Thanks very much! (I didn't even realize I was using GDI+ specific functionality.) That solved all but one of my issues.

My only remaining problem occurs on this line:
Code:
MigraDoc.DocumentObjectModel.TextMeasurement tm = new TextMeasurement(pStyle.Font);

Results in the error:
Quote:
The type or namespace name 'TextMeasurement' could not be found (are you missing a using directive or an assembly reference?)

I'm sorry to ask here (since it is somewhat unrelated to the topic), but I think it may be relevant to the libraries I am using. (I cannot find TextMeasurement anywhere in the GDI+ files.) Did something happen to it? Am I using depreciated functionality?

I'm looking forward to testing this once my compiler tells me I can. ;)

Author:  TH-Soft [ Tue Sep 22, 2015 3:04 pm ]
Post subject:  Re: Fast table rendering in MigraDoc

The class TextMeasurement was removed, that's all I can say today.
I don't know why it was removed, but the implementation was somewhat inaccurate and it was platform-specific and MigraDoc should be platform-independent.

I'll think about possible solutions.

Author:  TH-Soft [ Tue Sep 22, 2015 4:49 pm ]
Post subject:  Re: Fast table rendering in MigraDoc

yellowmosquito wrote:
I cannot find TextMeasurement anywhere in the GDI+ files.)
I have a replacement you can add to your project:
viewtopic.php?p=9390#p9390
There could be small differences with respect to the measured values.

Author:  yellowmosquito [ Tue Sep 22, 2015 6:59 pm ]
Post subject:  Re: Fast table rendering in MigraDoc

Thanks Thomas,

I appreciate the help. I'll try to get to it soon, and follow up with feedback about that feature in the thread you provided.

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