PDFsharp & MigraDoc Foundation https://forum.pdfsharp.net/ |
|
pdfRenderer.RenderDocument is extremely slow https://forum.pdfsharp.net/viewtopic.php?f=2&t=2027 |
Page 1 of 1 |
Author: | kko [ Tue May 22, 2012 1:50 am ] |
Post subject: | pdfRenderer.RenderDocument is extremely slow |
I got a document with a table which has 1200 rows and 3 columns. I also have a simple header and a footer. This is the part of the code where I render the document: Code: TimeSpan first; TimeSpan second; Stopwatch sw = new Stopwatch(); sw.Start(); document.UseCmykColor = true; const bool unicode = false; const PdfFontEmbedding embedding = PdfFontEmbedding.Always; PdfDocumentRenderer pdfRenderer = new PdfDocumentRenderer(unicode, embedding); pdfRenderer.Document = document; pdfRenderer.RenderDocument(); sw.Stop(); first = sw.Elapsed; sw.Start(); MemoryStream stream = new MemoryStream(); pdfRenderer.Save(stream, false); StringBuilder sb = new StringBuilder(); sw.Stop(); second = sw.Elapsed; First = 1 minute 53 seconds Second= 1 second this is how I add rows to a table: Code: foreach (var name in names) { Row row1 = table.AddRow(); row1.Cells[1].AddParagraph(name.ToString()); } is there any solution to this problem? |
Author: | mr_Hilter [ Wed Sep 02, 2015 11:24 am ] |
Post subject: | Re: pdfRenderer.RenderDocument is extremely slow |
if its still relevant viewtopic.php?f=2&t=679 |
Author: | TH-Soft [ Tue Sep 22, 2015 7:16 am ] |
Post subject: | Re: pdfRenderer.RenderDocument is extremely slow |
mr_Hilter wrote: if its still relevant Now we have two solutions for the problem: with PDFsharp 1.50 beta 2, MigraDoc table rendering got much faster.For my tests I used test code that creates a PDF with 26 pages, containing a single table with 666 rows that runs from page 2 through page 25. Test routine creates six such documents and shows the time required for each document. First document takes a bit slower, maybe due to assembly initialization and JIT compiling. Speed gain will be smaller for documents containing much text outside tables or containing no tables at all. 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 I do not publish my test code at this time. I am looking forward to seeing test results from others. The detailed timing for those who care: PDFsharp + MigraDoc WPF 1.32.2608: Creating document #0 Time: 25.131 Creating document #1 Time: 24.245 Creating document #2 Time: 24.272 Creating document #3 Time: 24.421 Creating document #4 Time: 24.158 Creating document #5 Time: 24.433 MigraDoc-1.32-patched-release (WPF) from Pakeha: Creating document #0 Time: 9.761 Creating document #1 Time: 8.967 Creating document #2 Time: 8.987 Creating document #3 Time: 8.986 Creating document #4 Time: 8.999 Creating document #5 Time: 8.985 PDFsharp + MigraDoc (WPF) 1.50.3638-beta: Creating document #0 Time: 16.756 Creating document #1 Time: 15.944 Creating document #2 Time: 15.972 Creating document #3 Time: 15.987 Creating document #4 Time: 16.026 Creating document #5 Time: 16.001 PDFsharp + MigraDoc (WPF) 1.50.3915-beta2: Creating document #0 Time: 2.223 Creating document #1 Time: 1.427 Creating document #2 Time: 1.436 Creating document #3 Time: 1.425 Creating document #4 Time: 1.418 Creating document #5 Time: 1.423 |
Author: | gastan [ Wed Aug 18, 2021 9:23 pm ] |
Post subject: | Re: pdfRenderer.RenderDocument is extremely slow |
I have PDFsharp-MigraDoc-gdi 1.50.5147 and creating report is rather slow. Is there an easy way to convert to WPF? Will it be faster ? |
Author: | TH-Soft [ Thu Aug 19, 2021 7:11 am ] |
Post subject: | Re: pdfRenderer.RenderDocument is extremely slow |
gastan wrote: Is there an easy way to convert to WPF? You only have to change the code if you use members that only exist in the GDI+ build. Try the other package and see if your project still compiles.gastan wrote: Will it be faster? Not sure, but I think it will rather be faster than slower.gastan wrote: I have PDFsharp-MigraDoc-gdi 1.50.5147 and creating report is rather slow. What is "rather slow"?Table rendering is still time-consuming. A document re-design could help to make it faster, too. |
Author: | gastan [ Thu Aug 19, 2021 9:34 pm ] |
Post subject: | Re: pdfRenderer.RenderDocument is extremely slow |
thx. Well I replaced package from gdi to wpf and only have two errors. Both are: 'XGraphics' does not contain a definition for 'FromGraphics' below is code where I am getting gfx to draw specific charts/figures into it. Drawing is the saved to FS and inserted back into PDF as I was unable to insert it diretly. Any ideas how to replace missing code? Code: Graphics graphics = Graphics.FromImage(image); graphics.Clear(System.Drawing.Color.White); float scale = dpi / 72f; graphics.ScaleTransform(scale, scale); // Create an XGraphics object and render the page XGraphics gfx = XGraphics.FromGraphics(graphics, new XSize(dx, dy)); DrawVerticalArcs(gfx, dVal, 160, 3); |
Author: | TH-Soft [ Fri Aug 20, 2021 1:28 pm ] |
Post subject: | Re: pdfRenderer.RenderDocument is extremely slow |
gastan wrote: Any ideas how to replace missing code? Hard so say with just that code snippet. And off-topic in this table-speed thread.Do you need XGraphics class here? Use Graphics class to manipulate the image. |
Page 1 of 1 | All times are UTC |
Powered by phpBB® Forum Software © phpBB Group https://www.phpbb.com/ |