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

XGraphics.DrawString hanging on production Server only
https://forum.pdfsharp.net/viewtopic.php?f=2&t=1635
Page 1 of 1

Author:  jdaigle@kbhmaine.org [ Mon Apr 25, 2011 8:27 pm ]
Post subject:  XGraphics.DrawString hanging on production Server only

Inside of a ASP.net Web application, we are using PDFSharp to take an image of a signature, and also a Date string, and stamp them on a PDF. It was tested and working at one point on the production server(Windows Server 2003). The line of code that the debugger hits prior to jsut hanging for an indefinite amount of time is: gfxSigPage.DrawString...
If that line of code is commented out, it will still hang on the DrawImage line below it.
This exact code works perfectly fine on my development machine still, and as i said worked at one point on the server.

If anyone has any ideas, they would be greatly appreciated,
Thanks,
Jeremiah

Code:
Array mySigImg = mySig.GetImageBytes(100, 100, FILETYPE.GIF, 100, 100);
                        Stream sigStream = new MemoryStream((byte[])mySig.GetImageBytes(100, 100, FILETYPE.GIF, 100, 100));
                        Stream pdfStream = new MemoryStream(bytFile, 0, bytFile.Length, true, true);

                        //create PDF object
                        PdfSharp.Pdf.PdfDocument myPDF = PdfSharp.Pdf.IO.PdfReader.Open(pdfStream, PdfSharp.Pdf.IO.PdfDocumentOpenMode.Modify);

                        //find last page, which is sig page
                        int SigPageNumber = myPDF.PageCount - 1;
                        //load last page into xGraphics object
                        PdfSharp.Drawing.XGraphics gfxSigPage = PdfSharp.Drawing.XGraphics.FromPdfPage(myPDF.Pages[SigPageNumber]);
                        //create system image file, that the image stream can be written to.
                        Bitmap bmp = new Bitmap(sigStream);

                        PdfSharp.Drawing.XFont fontArial = new PdfSharp.Drawing.XFont("Arial", 12);
                        PdfSharp.Drawing.XPoint pdfPoint = new PdfSharp.Drawing.XPoint(450, 347);

                        //create image object to add to that page, filling it with the bmp created above
                        PdfSharp.Drawing.XImage sigImage = PdfSharp.Drawing.XImage.FromGdiPlusImage((System.Drawing.Image)bmp);
                        gfxSigPage.DrawString(SignedDate, fontArial, PdfSharp.Drawing.XBrushes.Black, pdfPoint);
                        gfxSigPage.DrawImage(sigImage, 200, 320);

                        Stream finalpdfStream = new MemoryStream();

                        myPDF.Save(finalpdfStream, false);
                        bytFile = StreamToByteArray(finalpdfStream);

Author:  Thomas Hoevel [ Tue Apr 26, 2011 11:32 am ]
Post subject:  Re: XGraphics.DrawString hanging on production Server only

Hi, Jeremiah!
jdaigle@kbhmaine.org wrote:
This exact code works perfectly fine on my development machine still, and as i said worked at one point on the server.

Never change a running system. :wink:

Could be related to the rights of the identity associated with the Application Pool. You could try identity System to see if it works then.

Author:  jdaigle@kbhmaine.org [ Tue Apr 26, 2011 12:04 pm ]
Post subject:  Re: XGraphics.DrawString hanging on production Server only

I know this may sound naive, and I'll probably regret saying this later when I realize something changed that I was unaware of... but as far as I can tell nothing has changed. And my assumption from the beggining was that something changed, so I have looked very hard for any possible changes(source control, Web.Config, Server Settings, DLL reference changes), and found absolutely nothing.

We have a domain account that our app pool identity runs as, but I have tested it with all the other options in the identity tab. It still does not work with Local System set as the app pool identity. After making these changes I restarted IIS, to make sure the changes took effect.

I have also cleared out the Temporary APS.net Files and restarted the server, which has given us possitive results in the past, when debugging something that was seeming to be unexplainable. But it still does the same thing.

Author:  Thomas Hoevel [ Tue Apr 26, 2011 4:16 pm ]
Post subject:  Re: XGraphics.DrawString hanging on production Server only

jdaigle@kbhmaine.org wrote:
... but as far as I can tell nothing has changed.

You can never be sure of that in the days of Microsoft Update, Patch Tuesdays, and Exploit Wednesdays ...

Changes in the document? Different font maybe?

Try the Release build. Maybe you switched from Debug to Release?

I thought it was a rights problem. But if the Local System account fails, it probably is not a rights problem.

Author:  jdaigle@kbhmaine.org [ Wed Apr 27, 2011 1:34 pm ]
Post subject:  Re: XGraphics.DrawString hanging on production Server only

Looks like the Define DEBUG Constant setting in the build configuration was checked in the original DLL, When I unchecked that and republished the problem went away. Actually I changed my configuration mode to Release instead of debug... but to pin down exactly which one made the difference from working on the production server, i modified one setting at a time in the debug Config mode. In the end the only way I could get it to work again on my production server, was to publish the version with the Define DEBUG Constant Unchecked.
I have no problems on my local dev machine when running the web app with that Define DEBUG Constant checked... and initially when this was deployed to production with that setting checked off, it was working.

Thanks for your help,
Jeremiah

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