Table of Contents
  • Getting Started
  • EO.Pdf
  • EO.Web
    • Overview
    • Installation & Deployement
    • EO.Web ToolTip
    • EO.Web Rating
    • EO.Web Slider & RangeSlider
    • EO.Web ListBox
    • EO.Web ComboBox
    • EO.Web Captcha
    • EO.Web ASPX To PDF
    • EO.Web Slide
    • EO.Web Flyout
    • EO.Web EditableLabel
    • EO.Web ImageZoom
    • EO.Web Floater
    • EO.Web Downloader
    • EO.Web ColorPicker
    • EO.Web HTML Editor
    • EO.Web File Explorer
    • EO.Web SpellChecker
    • EO.Web Grid
    • EO.Web MaskedEdit
    • EO.Web Splitter
    • EO.Web Menu
    • EO.Web Slide Menu
    • EO.Web TabStrip
    • EO.Web TreeView
    • EO.Web Calendar
    • EO.Web Callback
    • EO.Web MultiPage
    • EO.Web Dialog
    • EO.Web AJAXUploader
    • EO.Web ProgressBar - Free!
    • EO.Web ToolBar - Free!
  • EO.WebBrowser
  • EO.Wpf
  • Common Topics
  • Reference


ASPXToPDF is an intuitive ASP.NET server control that allows you to "export" any ASP.NET Web page to a PDF file. It is built on top of the more generic HTML to PDF feature provided by EO.Pdf.

Before You Begin

In order to use ASPXToPDF, your project must:

  1. Be an ASP.NET Web project using Web Forms. ASPXToPDF is an ASP.NET server control and will only work with ASP.NET Web Forms. If your project is not an ASP.NET Web Form project, uses the more generic HTML to PDF converter interface directly, or use MVC to PDF if your application is an ASP.NET MVC application.
  2. ASPXToPDF is declared in EO.Web.dll. So you must reference that DLL first. If you have downloaded and installed EO.Total, then ASPXToPDF should already be in your Visual Studio's toolbox. In that case you can simply drag and drop ASPXToPDF from Visual Studio's toolbox to your Web Form to place the control in your form and add the reference at the same time.
  3. The actual HTML to PDF conversion relies on EO.Pdf.dll. Thus make sure that DLL is in your application's bin directory. You can find EO.Pdf.dll in EO.Total's installation folder (the default location is "Program Files\Essential Objects\EO.Total xxx", where "xxxx" is the version number, or "Program Files (x86)\Essential Objects\EO.Total xxx" on a 64 bit system).

    You do not have to reference EO.Pdf.dll directly. However since the conversion relies on EO.Pdf, almost all EO.Pdf options can be used. If you wish to use any of those options (for example, you can set page size by setting HtmlToPdf.Options.PageSize property ), then you must reference EO.Pdf.dll;


Using ASPXToPDF is extremely simple and straight forward. To use the control, simply drag it from your toolbox to your Web Form. Only one ASPXToPDF control is needed in any page.

If you do not have it on your toolbox, add the following code to the top of your page:

<!--  Register "eo" tag prefix  -->
<%@ Register assembly="EO.Web" namespace="EO.Web" tagprefix="eo" %>

Then define ASPXToPDF control in your page:

<!--  Place a single ASPXToPDF control in the page  -->
<eo:ASPXToPDF runat="server" ID="ASPXToPDF1" />

Once the control is in your page, simply call the control's RenderAsPDF method to render the page as PDF. For example, the following code renders the page as PDF when Button1 is clicked:

<asp:Button runat="server" ID="Button1" 
    OnClick="Button1_Click" />

Convert a portion of the Page

To convert a portion of your page instead of the whole page, set HtmlToPdfOptions.VisibleElementIds to the ID of the DHTML element you wish to convert. Note this ID is the DHTML element ID, not your ASP.NET server control ID. Usually the DHTML element ID is the same as your control's ClientID.

Save Conversion Result into a File

By default, ASPXToPDF sends the result directly to the client. You can use the following code to turn this behavior off (note the "false" argument passed to the call):

//Render the page as PDF but do not send it to the client

In order to save the conversion result into a file, you can handle the ASPXToPDF control's AfterRender event, then use the HtmlToPdf.Result to access the conversion result. The following code demonstrates how to do this:

//Get the conversion result
HtmlToPdfResult result = HtmlToPdf.Result;

//Save the conversion result to a file

Change "Save As" File Name

By default, ASPXToPDF uses the current page file name as the suggested "Save As" file name for the PDF file. For example, if the current page name is "Page1.aspx", the suggested PDF file name would be "Page1.pdf".

You can change this behavior by providing your own file name when calling RenderAsPDF. For example, the following code demonstrates how to use "Report.pdf" as the suggested file name:

//Use "Report.pdf" as the suggested "Save As" file name

Additional Options

Since ASPXToPDF relies on EO.Pdf to function, you can use almost all EO.Pdf options. In order to use EO.Pdf options, you must reference EO.Pdf.dll first. After you have added reference to EO.Pdf.dll, you can use almost all EO.Pdf options. For example, you can follow instructions here on how to set output page size.

Additional Samples

Both EO.Web Controls and EO.Pdf include samples about the ASPXToPDF control. EO.Web Controls include the following samples (inside "Samples\Web" subdirectory):

  • Basic Feature. Demonstrating the basic feature of the control.
  • Customize Save As File Name. Demonstrating how to customize the suggested file name when the browser prompts user to save or open the PDF file.
  • BeforeRender Event. Demonstrating how to use BeforeRender event to customize HTML to PDF conversion options.
  • AfterRender Event. Demonstrating how to use AfterRender event to add additional output to the converted PDF document.

To run these samples, first install EO.Total, then select All Programs -> EO.Total xxx -> Samples -> EO.Web -> Live Demo Start Page C#/VB.NET from your Windows start menu. Alternatively, you can also select "Live Demo Source Code" to navigate to the demo source code directory.

EO.Pdf includes a single "ASPXToPDF" sample that demonstrates saving and reading data in session variables and then generates PDF output based on those values. To run EO.Pdf ASPXToPDF samples, select All Programs -> EO.Total xxx -> Samples -> EO.Pdf -> EO.Pdf Web Demo from your Windows start menu. You can also select "EO.Pdf Web Demo Source" to navigate to the demo source code directory.

Additionally, ASPXToPDF returns a PdfDocument object. Any EO.Pdf API that works with a PdfDocument object can be used together with ASPXToPDF to perform additional task on the converted result, such as adding additional content or save it to a file. EO.Pdf includes dozens of samples about these features. To run these samples, select All Programs -> EO.Total xxx -> EO.Pdf -> EO.Pdf Demo from your Windows start menu, (or select "EO.Pdf Demo Source" to navigate to the source directory).

License and Deploy

You only need a license for the EO.Pdf product in order to use this feature. You do not need a license for the EO.Web Controls product even though the control is declared in EO.Web.dll.

To deploy to the production server, you must include all EO.Pdf DLLs as well as EO.Web.dll in your application's bin folder and properly apply EO.Pdf license key.