To do work with ASP.NET, we must perform three steps:
- Create an Interop-wrapper
- Copy the wrapper into a specific folder
- 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 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)
Example:
TlbImp.exe PDFCreatorPilot3.dll /out:Interop.PDFCreatorPilot3Lib.dll
Then we need to 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.)
Example:
If our web-application is located in “C:\Inetpub\wwwroot\MyApp”, then we should put the wrapper into “C:\Inetpub\wwwroot\MyApp\bin”.
To attach the web-application to the namespace library, we should append the following line to the “.aspx”-file:
<%@ Import Namespace="Interop.PDFCreatorPilot3Lib.dll" %>
After that, a COM-object of PDF Creator Pilot may be used from ASP.NET.
Example:
<%@ Import Namespace="System" %>
<!-- other import directives are here -->
<%@ Import Namespace="Interop.PDFCreatorPilot3Lib.dll" %>
<HTML> <HEAD>
<TITLE>Test</TITLE>
<SCRIPT language="C#" runat="server">
void ButtonPerform_Click(object sender, System.EventArgs e)
{
PDFDocument3Class pdf = new PDFDocument3Class();
pdf.StartEngine("demo@demo", "demo");
pdf.AutoCreateURL = true;
// set other options if needed
pdf.BeginDoc();
// do something
pdf.EndDoc();
}
</SCRIPT>
</HEAD>
<BODY>
<!-- 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" />
</FORM>
</BODY>
</HTML>
Maxim Filimonov