PDFsharp - moved to http://forum.pdfsharp.net/ Forum Index PDFsharp - moved to http://forum.pdfsharp.net/
Please visit the new PDFsharp forum at http://forum.pdfsharp.net/
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

PDFDocument.Save possibly failing.

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    PDFsharp - moved to http://forum.pdfsharp.net/ Forum Index -> Support - moved to http://forum.pdfsharp.net/
View previous topic :: View next topic  
Author Message
carter



Joined: 10 Mar 2009
Posts: 2

PostPosted: Tue Mar 10, 2009 6:33 pm    Post subject: PDFDocument.Save possibly failing. Reply with quote

I'm running pdfsharp on a few terminals and about 5-10 times a day i'm finding 0kb pdf files that are being saved. The logic i have is inside a try/catch and my software isn't reporting any errors. I checked out the source for the pdfdocument object and i found under the public void Save(Stream stream, bool closeStream) there is just a try/finally. So it would seem that if there is any execption whatsoever then it would get ignored. I could check the length of the stream to check to see if the stream has been successfully written to, but what if the write fails 4kb through? Also, i'd like to know what the exception is so i could find out whether it is a permissions problem, os problem, or software problem. Below is the code i am using.

Code:
      FileStream ^fs = File::Create(sFileNamePath);
      fs->SetLength(0);

      PdfDocument ^pdfDocument = gcnew PdfDocument(fs);

      for each (Image ^img in arrImages)
      {
         PdfPage ^page = pdfDocument->AddPage();
         page->Orientation = PdfSharp::PageOrientation::Landscape;

         XGraphics ^graphics = XGraphics::FromPdfPage(page);
         XImage ^xImage = XImage::FromGdiPlusImage(img);

         graphics->DrawImage(xImage, Point(10, 10));
      }

      pdfDocument->Save(fs, false);
Back to top
View user's profile Send private message
Thomas Hoevel



Joined: 16 Oct 2006
Posts: 387
Location: Cologne, Germany

PostPosted: Wed Mar 11, 2009 9:06 am    Post subject: Re: PDFDocument.Save possibly failing. Reply with quote

Hi!
carter wrote:
I checked out the source for the pdfdocument object and i found under the public void Save(Stream stream, bool closeStream) there is just a try/finally. So it would seem that if there is any execption whatsoever then it would get ignored.

I don't think that exceptions are ignored by try/finally without catch.
Could be tested by adding something like
Code:
catch/*(Exception ex)*/
{
  throw;
}

to the try/finally statements.
_________________
Regards
Thomas Hoevel
PDFsharp Team
Back to top
View user's profile Send private message Visit poster's website
carter



Joined: 10 Mar 2009
Posts: 2

PostPosted: Wed Mar 11, 2009 3:23 pm    Post subject: Re: PDFDocument.Save possibly failing. Reply with quote

Thomas Hoevel wrote:
I don't think that exceptions are ignored by try/finally without catch.


You're right. I thought for sure that try/finally was the equivalent to "On Error Resume.." in vb. I'll do more testing and see what i can come up with.
Back to top
View user's profile Send private message
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    PDFsharp - moved to http://forum.pdfsharp.net/ Forum Index -> Support - moved to http://forum.pdfsharp.net/ All times are GMT
Page 1 of 1

 
Jump to:  
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 vote in polls in this forum


Powered by phpBB © phpBB Group. Hosted by phpBB.BizHat.com


Start Your Own YouTube Clone

Free Web Hosting | Free Forum Hosting | FlashWebHost.com | Image Hosting | Photo Gallery | FreeMarriage.com

Powered by PhpBBweb.com, setup your forum now!
For Support, visit Forums.BizHat.com