How to Create a PDF with ASP.NET on a Web Server without Visual Studio
Knowledge Base :: PDF Creator Pilot 4 Knowledge Base

See Also Example
Collapse All

To enable PDF Creator Pilot to work with ASP.NET, you must perform three steps:

  1. Create an Interop wrapper.
  2. Copy the wrapper into a specific folder.
  3. Attach the namespace libraries to the application.

To create the Interop wrapper of PDF Creator Pilot (i.e. a wrapper that would make it possible to call the unmanaged COM object code of the library from the managed code of an ASP.NET application), we should use one of the standard utilities from the .NET SDK - TlbImp.exe (C:\Program Files\Microsoft SDKs\Windows\v6.0A\bin\TlbImp.exe)


TlbImp.exe PDFCreatorPilot.dll /out:Interop.PDFCreatorPilotLib.dll

Then copy the wrapper into the "bin" subfolder of the Web application root folder. (If that folder does not yet exist, we will have to create it.)


If the Web application is located in "C:\Inetpub\wwwroot\MyApp", then put the wrapper into "C:\Inetpub\wwwroot\MyApp\bin".

To attach the Web application to the namespace library, append the following line to the ".aspx"-file:

<%@ Import Namespace="Interop.PDFCreatorPilotLib" %>

After that, a COM object of PDF Creator Pilot may be used from ASP.NET.

Important: after updating a PDF Creator Pilot to a new version you must update your Interop-wrappers also.


Using PDF Creator Pilot in an ASP.NET Page

[copy to clipboard]
<%@ Import Namespace="System" %>
<!-- other import directives are here -->
<%@ Import Namespace="Interop.PDFCreatorPilotLib" %>
  <SCRIPT language="C#" runat="server">
    void ButtonPerform_Click(object sender, System.EventArgs e)
      PDFDocument4Class pdf = new PDFDocument4Class();
      pdf.SetLicenseData("demo@demo", "demo");
      pdf.AutoCreateURL = true;
      // set other options if needed
      // do something
      pdf.SaveToFile("path\\saved.pdf", false);
  <!-- here page content goes -->
  <FORM runat="server">
    <INPUT type="button" id="ButtonPerform" value="Click Me"
      OnServerClick="ButtonPerform_Click" runat="server" />
    <!-- or another vaiant -->
    <asp:Button id="ButtonPerform1" Text="Click Me"
      OnClick="ButtonPerform_Click" runat="server" />

See Also