PDFsharp & MigraDoc Foundation

PDFsharp - A .NET library for processing PDF & MigraDoc Foundation - Creating documents on the fly
It is currently Sun Jul 14, 2024 10:18 pm

All times are UTC


Forum rules


Please read this before posting on this forum: Forum Rules



Post new topic Reply to topic  [ 5 posts ] 
Author Message
PostPosted: Mon Apr 25, 2011 8:27 pm 
Offline

Joined: Mon Apr 25, 2011 8:06 pm
Posts: 3
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);


Top
 Profile  
Reply with quote  
PostPosted: Tue Apr 26, 2011 11:32 am 
Offline
PDFsharp Guru
User avatar

Joined: Mon Oct 16, 2006 8:16 am
Posts: 3101
Location: Cologne, Germany
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.

_________________
Regards
Thomas Hoevel
PDFsharp Team


Top
 Profile  
Reply with quote  
PostPosted: Tue Apr 26, 2011 12:04 pm 
Offline

Joined: Mon Apr 25, 2011 8:06 pm
Posts: 3
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.


Top
 Profile  
Reply with quote  
PostPosted: Tue Apr 26, 2011 4:16 pm 
Offline
PDFsharp Guru
User avatar

Joined: Mon Oct 16, 2006 8:16 am
Posts: 3101
Location: Cologne, Germany
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.

_________________
Regards
Thomas Hoevel
PDFsharp Team


Top
 Profile  
Reply with quote  
PostPosted: Wed Apr 27, 2011 1:34 pm 
Offline

Joined: Mon Apr 25, 2011 8:06 pm
Posts: 3
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


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

All times are UTC


Who is online

Users browsing this forum: Bing [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:  
cron
Privacy Policy, Data Protection Declaration, Impressum
Powered by phpBB® Forum Software © phpBB Group