|
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?
|
|
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!
|
|
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?
|
|
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.
|
|