Rank: Newbie Groups: Member
Joined: 10/28/2012 Posts: 2
|
Hi We recently installed you product in our web site and our clients are able to produce reports to pdf. I'm trying now to develope a massive report production (from a list of reports) I first tried to do that from the server side, by writing the full HTML code and using htomToPdf. the produced reports didn't contain all the styling from the appropiate css files. Then I've tried to use ASPTtoPDF, each time i'm loading the page and exporting it to pdf. when i do it one by one it works fine. but when I'm trying to run it as batch by activating the exportToPdf button click on page load. now the after_render event stoped working froperly. please advice how can i implement such behavior.
Thanks
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,195
|
Hi,
You can't do multiple rendering with ASPXToPDF on a single pass. If you want to do multiple pass, you have to use ConvertHtml/ConvertUrl. If you use ConvertHtml, then you must set HtmlToPdf.Options.BaseUrl correctly.
Additionally, if your application is an ASP.NET application and your conversion takes a long time, you will need to consider move your code into a background thread. ASP.NET will kill your page thread if it detects one request takes too long.
Thanks!
|
Rank: Newbie Groups: Member
Joined: 10/28/2012 Posts: 2
|
I'm afraid i wasn't explaining well the situation. the pdf files production is not done on a single pass. after each render I'm redirecting the application (response.redirect) again to the same page after changing some session data. after the page is reloaded with the new parameters, the automatic click is fired and the loop runs again.
regarding performance, the batch process will run on a local env and not over the web.
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,195
|
Hi,
I don't think you can do Response.Redirect and ASPXToPDF at the same time. Response.Redirect write into the header, ASPXToPDF writes into the response body (the conversion is done AFTER rendering since ASPXToPDF needs the full page HTML output). So Response.Redirect is always called before the PDF file is generated. However when you do that ASP.NET will terminate the whole request before it determined that you are abandoning the current page since you wish to direct a different page, thus canceling the current page request. As such the request will never reach the final stage when ASPXToPDF actually does the conversion.
A workaround for you would be writing some JavaScript code to the page to trigger the reload, instead of doing Response.Redirect. For example, you can put a Label in your page, then set the Label's Text to something like "<script type='text/javascript'>some JavaScript code</script>" to run any JavaScript code. That way when the client side browser loads the page, it will run whatever code you put in. In that code you can then redirect to a different Url. The main different about this approach is the redirection is done in the HTML body, not in the HTML header, and not through ASP.NET either. So instead of terminating your current request, ASP.NET will allow your current request to finish normally.
Thanks!
|