|
Rank: Newbie Groups: Member
Joined: 4/23/2013 Posts: 3
|
Hi, I am using the trial version of EO.PDF software to check whether the software can be used in our project. My requirement is that i will have links to aspx pages which needs to be downloaded as PDF from a separate page for download. For Ex: http://www.abc.com/Sample.aspx?mySampleId=1125Consider that i am in download page and the above link is in a text box. On click of a button, I am converting the above link to html and passing the html to the following code HtmlToPdf.ConvertHtml(myPageHTML, pdfDoc); But the output i get is of the login page instead of the sample.aspx with specific id 1125 page. Is there a solution for this ?
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,195
|
Hi, That's normal. If that page requires login, then you have to login. The key is your session (session A) and the HTML to PDF converter session (session B) are two DIFFERENT sessions. Your session (session A) is between your computer and your Web server. The HTML to PDF converter session (session B) is between your web server (assuming HTML to PDF converter runs on your web server) and another (or the same) web server. Session A have logged in does not mean session B have logged in. There are a number of options for you "log in" your server with HTML to PDF converter. 1. Capture your site's authentication cookie, then add it to HtmlToPdf.Options.Cookies; 2. Use HtmlToPdfSession object: http://www.essentialobjects.com/doc/4/htmltopdf/session.aspx3. Add a "pass key" argument to your page so that you page will be able to bypass authentication if it sees that argument. For example: http://www.abc.com/Samples.aspx?mySampleId=1125&passKey=6789Each method has its advantage and disavantages. This page contains a good discussion about both method 1 and method 2, which should give you some basic ideas about page authentications: http://www.essentialobjects.com/forum/postst7136_How-to-convert-SharePoint-Online-page-to-PDF.aspxMethod 3 is straight forward but requires additional coding on your server side to check and verify the "passKey", and if not done properly, it can be easily exploited. Hope this helps. Please feel free to let us know if you have any more questions. Thanks!
|
|
Rank: Newbie Groups: Member
Joined: 4/23/2013 Posts: 3
|
Hi, Thank you for providing the information. I have used option 1(Adding Cookie) from the above message. The following is the code i used to generate the pdf
Code: C#
PdfDocument doc = new PdfDocument();
HtmlToPdf.ConvertUrl(currentPageUrl, doc);
////Setup HttpResponse headers
HttpResponse response = HttpContext.Current.Response;
response.Clear();
response.ClearHeaders();
response.ContentType = "application/pdf";
//Send the PdfDocument to the client
doc.Save(response.OutputStream);
Response.End();
I need one more information, Currently the PDF file is getting generated in the browser tab itself. How can i show a save dialog instead, so that the user can save the PDF file to the location of his preferred choice ?
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,195
|
Hi,
The generic version of your question is "how to show a save dialog for a dynamically generated file". We consider that a Web development question rather a question directly related to our product. So it won't be covered by our support. You can search online and you should be able to find plenty of information on that.
Thanks!
|
|
Rank: Newbie Groups: Member
Joined: 4/23/2013 Posts: 3
|
Hi, As i stated in my first post, i will be having multiple dynamic links on a page, and on a button click i need to download all into separate PDF files.
I am able to convert one link and download to PDF at present. But you cannot download multiple PDFs in the same page response.
Will any control from EO (For Ex: Downloader) help in converting the dynamic links and downloading multiple files from a button click ?
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,195
|
Hi,
You can merge multiple links into a single PDF file, then download that single PDF file. But you can not download multiple files with one click in a Web Browser. This has nothing to do with us ---- it's just how Web page works. Web pages works by one request, one response. This is why you can not download multiple files with one request.
Thanks!
|
|