PDFsharp & MigraDoc Foundation

PDFsharp - A .NET library for processing PDF & MigraDoc Foundation - Creating documents on the fly
It is currently Fri Dec 03, 2021 1:35 pm

All times are UTC


Forum rules


Please read this before posting on this forum: Forum Rules



Post new topic Reply to topic  [ 7 posts ] 
Author Message
PostPosted: Tue May 22, 2012 1:50 am 
Offline

Joined: Thu May 10, 2012 11:52 pm
Posts: 7
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?


Top
 Profile  
Reply with quote  
PostPosted: Wed Sep 02, 2015 11:24 am 
Offline

Joined: Wed Sep 02, 2015 10:56 am
Posts: 2
if its still relevant

viewtopic.php?f=2&t=679


Top
 Profile  
Reply with quote  
PostPosted: Tue Sep 22, 2015 7:16 am 
Offline
PDFsharp Expert
User avatar

Joined: Sat Mar 14, 2015 10:15 am
Posts: 683
Location: CCAA
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

_________________
Best regards
Thomas
(Freelance Software Developer with several years of MigraDoc/PDFsharp experience)


Top
 Profile  
Reply with quote  
PostPosted: Wed Aug 18, 2021 9:23 pm 
Offline

Joined: Sat Oct 18, 2008 4:15 pm
Posts: 43
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 ?


Top
 Profile  
Reply with quote  
PostPosted: Thu Aug 19, 2021 7:11 am 
Offline
PDFsharp Expert
User avatar

Joined: Sat Mar 14, 2015 10:15 am
Posts: 683
Location: CCAA
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.

_________________
Best regards
Thomas
(Freelance Software Developer with several years of MigraDoc/PDFsharp experience)


Top
 Profile  
Reply with quote  
PostPosted: Thu Aug 19, 2021 9:34 pm 
Offline

Joined: Sat Oct 18, 2008 4:15 pm
Posts: 43
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);


Top
 Profile  
Reply with quote  
PostPosted: Fri Aug 20, 2021 1:28 pm 
Offline
PDFsharp Expert
User avatar

Joined: Sat Mar 14, 2015 10:15 am
Posts: 683
Location: CCAA
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.

_________________
Best regards
Thomas
(Freelance Software Developer with several years of MigraDoc/PDFsharp experience)


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

All times are UTC


Who is online

Users browsing this forum: Bing [Bot], Google [Bot] and 20 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