Table of Contents
- Getting Started
- Installation and Deployment
- Using HTML to PDF
- Using HTML to PDF
- Quick Start
- Setting Page Size and Margins
- Resizing Output
- Output Paging
- Web Page Authentication
- HTTP Post and Headers
- Conversion Trigger
- Links in HTML
- Page Header and Footer
- Partial Page Conversion
- Repeating Table Header and Footer
- Merging Multiple HTML pages
- Generating Page Images
- Using with PDF Creator
- Creating Interactive Form Elements
- Working with Secure Pages
- Using HtmlToPdfSession object
- Troubleshooting HTML to PDF
- Debugging HTML to PDF
- Using PDF Creator
- Working with Existing PDF Files
- Using in Web Application
- Advanced Topics
- Common Topics
|Web Page Authentication|
EO.Pdf HTML to PDF converter can convert any Web page your browser can open, however some web page may require authentication before access can be granted. In such case you must supply additional information to the converter so that the converter can "login" in order to be granted access to the page.
HTTP authentication is handled on the HTTP protocol level. When you access a page that requires HTTP authentication, the browser will display a login dialog for you to enter user name and password. Once you enter the correct user name and password, access is granted and the page is displayed.
EO.Pdf HTML to PDF converter can automatically login for you if the page requires HTTP authentication. To use this feature, you simply set HtmlToPdfOptions's UserName and Password to the user name and password for the page. EO.Pdf HTML to PDF converter will automatically use this information to login the remote server.
Note that UserName and Password are automatically cleared after each conversion. So you must set it again for each page that requires a user name and password.
EO.Pdf HTML to PDF automatically supports Windows authentication. The current user context in the thread that calls the converter will be used to authenticate a remote server if the server supports Windows authentication.
Form authentication is handled on the Web application level. When you access a page that requires form authentication, the application will redirect you to a login page. Once you enter the correct user name and password through the login page, your identification is established and access to the restricted pages is granted.
EO.Pdf HTML to PDF converter can also access these pages if the correct credential information is provided. However because the authentication is handled on the application level, different application may implement it differently, thus the exact way to pass such additional credential information varies between applications.
When a browser requests a page, it passes the following data to the server:
- The requested Url. This may include additional arguments. For example, "Report.aspx?report_id=1234" passes "1234" as "report_id". If additional information is passed to the server in the Url to establish user identity, you can just use the same Url for EO.Pdf HTML to PDF converter. All code should work the same way as if the page were being accessed by a browser, so no additional code is needed;
EO.Pdf HTML to PDF converter can both acquire such authentication cookies for you, or accept such cookies and send them to the server if you have already acquired such cookies through other means (or through EO.Pdf HTML to PDF converter earlier). To instruct EO.Pdf HTML to PDF converter to use a cookie, add the cookie to HtmlToPdfOptions.Cookies collection. The following code demonstrates how to add a cookie:
//Add a cookie HtmlToPdf.Options.Cookies.Add(cookie); //Convert a page. The cookie added by the above line will //be sent to the server HtmlToPdf.ConvertUrl(your_page_url);
- Form data. The request may also contain form data that makes sense to the server page. For example, a "CreateMessage.aspx" page may recognizes form variable such as "title", "msg_body", etc. Usually when user initially requests a page, a blank form is rendered, user would then fill in the form and upon submit, a new HTTP POST request is sent to the server with the filled in data. While form data are usually used for passing application related data to the server, it can also be used to pass identify information to the server. If that is the case, you must also provide such information to EO.Pdf Html to PDF converter in order to establish user identity on the server side. You can either use a HtmlToPdfSession object, or to use HTTP Post and Headers feature to post form data to the server.
ASP.NET Form Authentication
If your server application is based on ASP.NET and you would like to convert another page from within your application (for example, an "Export To PDF" button in your "OrderHistory.aspx" page), then the easiest way is to use ASPXToPDF control. ASPXToPDF not only automatically handles authentication cookies, but also handles ASP.NET session cookies. This allows the converter to access the current session's session variables as well. All other methods can handle authentications, but the request will be processed in a separate session, thus not able to share the current session's session variables.