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

XGraphics DrawImage Performance Issue
https://forum.pdfsharp.net/viewtopic.php?f=2&t=1921
Page 1 of 1

Author:  aracho [ Thu Feb 23, 2012 5:21 pm ]
Post subject:  XGraphics DrawImage Performance Issue

Hello, all.

I have a pretty standard usage of PDFSharp (or at least I think it's pretty standard), taking a PNG image from the file system, and rendering it onto the first page of a single-page PDF.

My issue is that it works perfectly well in all environments, except one, but the problem is that environment is production.

In production, the process actually does succeed all the time, but it takes an inordinately long time. In all other environments, the process takes 2-3s, whereas in the affected servers, it takes 30-35s. :shock:

Please see the attached image which shows the timings we have been seeing.

The server environment is nothing special: Windows Server 2008 SP2, 32-bit. .NET framework 4.0 and 3.5 is installed.

Here is the code:

Code:
var doc = new PdfDocument();
var pdfOutputFile = Global.TemporaryFolderPhysicalPath + "\\" + uniqueId + ".pdf";

var page = new PdfPage()
{
Width = SummaryOutputPdfWidth,
Height = SummaryOutputPdfHeight
};

doc.Pages.Add(page);

var xGraphics = XGraphics.FromPdfPage(doc.Pages[0]);
var sourceImage = XImage.FromFile(Global.TemporaryFolderPhysicalPath + "\\" + uniqueId + ".png");

double width = SummaryScreenshotWidth;
double height = SummaryScreenshotHeight;

xGraphics.DrawImage(sourceImage, 10, 10, width, height); // <= ** This is what takes the longest amount of time **

doc.Save(pdfOutputFile);
doc.Close();

return pdfOutputFile;

It's the line indicated above which seems to take a massive amount of time; frustratingly, this is something we are totally unable to replicate in any other environment, from local machine, all the way through staging.

Can anyone offer any thoughts on what could possibly cause such a slow-down on a particular environment? Any known interactions with other software (or something missing)?

Thanks much,

Allen

Attachments:
File comment: Shows the timings we have been seeing.
App_Production_Trace.jpg
App_Production_Trace.jpg [ 230.02 KiB | Viewed 5293 times ]

Author:  jonesfxr [ Fri Feb 24, 2012 11:14 am ]
Post subject:  Re: XGraphics DrawImage Performance Issue

Hi,
seems like I'm running into the similar issue.
While memory is releases on most workstation, when creating images in page of pdf,
one other memory is increasing immensly.

Any foundings so far.

regards
jones

Author:  () => true [ Sun Feb 26, 2012 8:18 am ]
Post subject:  Re: XGraphics DrawImage Performance Issue

Hi, Allen!
aracho wrote:
My issue is that it works perfectly well in all environments, except one, but the problem is that environment is production.
Are you using GDI+ build or WPF build? Have you tried the other build?
PNG, BMP, GIF, TIFF are all treated the same way by PDFsharp (but maybe the OS treats them different). Could you try BMP to see if it's faster?

Author:  jonesfxr [ Sun Feb 26, 2012 5:01 pm ]
Post subject:  Re: XGraphics DrawImage Performance Issue

Hi,
as asked before: Are you using GDI+ or WPF build?
If using GDI+, check for differences in gdiplus.dll version.
Not sure, if this is the reason for your issue, but I've seen differences
in my environments.
So, not knowing which FP would deliver the right dll version and which side effect replacing
only the gdiplus.dll would have, I tried to switch to WPF build.

At least on my systems, performance and mem issues are gone.

regards
jones

Author:  aracho [ Sun Mar 04, 2012 3:41 pm ]
Post subject:  Re: XGraphics DrawImage Performance Issue

Hi jones, Ohmesh -

Thank you for the replies!

I must be using the GDI+ build, since WPF is not involved in the application at all. I'll try see what I can discover about the version of gdiplus.dll. I have a feeling it must be something like that, since there is only one place where the application behaves like this (production). In all other places, it works perfectly, hence my suspicion that there is something different about production.

I'll take a look and report back here.

Regards,

Allen

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