Welcome Guest Search | Active Topics | Sign In | Register

Is PdfDocument.Save() asynchronous? Options
Droddy
Posted: Monday, March 24, 2014 9:51:45 AM
Rank: Member
Groups: Member

Joined: 1/22/2014
Posts: 20
In my application:
--The user clicks to generate the pdf
--My web app triggers a background job which uses HtmlToPdf to convert an URL to a pdf and then save the PDF to disk via PdfDocument.Save()
--The web page repeatedly poles the server to check for the job completion.
-- When the job is complete, the web app attempts to download the saved file to the user.

What I am finding is that the file does not always exist at this point. The web app returns "System.Exception: Cannot locate file '[path]'".

PdfDocument.Save() is a void return type so my job considers the error free completion of this step to mean that the saved file is available and reports back to the DB that the job is complete. Every time I get the error from the web app, I follow 'path' and find the file is indeed there. Is this a problem you've heard of before? Am I doing something wrong?
eo_support
Posted: Monday, March 24, 2014 10:05:49 AM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,196
Hi,

PdfDocument.Save is NOT asynchronous. The file should be there after the call returns unless it failed (in which case it should throw an exception). So you will want to debug your code to see why the file is missing.

Thanks!
Droddy
Posted: Monday, March 24, 2014 11:00:16 AM
Rank: Member
Groups: Member

Joined: 1/22/2014
Posts: 20
When I debug the code, by the time I check for the file, it's there. Can you confirm that PdfDocument.Save, ultimately, uses, simple, common, managed .NET System.IO to write the file?
eo_support
Posted: Monday, March 24, 2014 11:17:24 AM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,196
Yes. We create a .NET FileStream object from the file name, then call PdfDocument.Save(Stream) to save the file.


You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.