IMPORTANT!
If you use the Printer object, then make sure to
configure the easyPDF SDK
Loader object
ASP Setup:

|
<!--
METADATA TYPE="TypeLib"
NAME="BCL easyPDF Printer SDK 7 Type Library"
UUID="{EA8A1E91-64A1-4ddf-BBC5-F89F169D432B}"
VERSION="7.0"
-->
<!--
METADATA TYPE="TypeLib"
NAME="BCL easyPDF PDF Processor SDK 7 Type Library"
UUID="{CCE51F13-59D1-4e99-8187-AC1C2852691B}"
VERSION="7.0"
-->
<!--
METADATA TYPE="TypeLib"
NAME="BCL easyPDF PDF Converter SDK 7 Type Library"
UUID="{04E35557-0E8B-431c-9622-B3B7D7B2007D}"
VERSION="7.0"
-->
<!--
METADATA TYPE="TypeLib"
NAME="BCL easyPDF PDF Document SDK 7 Type Library"
UUID="{D1E38948-AEF4-4ee1-B7BF-75655FA5EAD2}"
VERSION="7.0"
-->
|
<%@ Language=VBScript %>
<%
Option Explicit
Dim oLoader
Dim oPrinter
Dim oPrintJob
' For ASP, instead of getting the Printer object directly,
' get it through the easyPDF SDK Loader object.
Set oLoader = Server.CreateObject("easyPDF.Loader.7")
Set oPrinter = oLoader.LoadObject("easyPDF.Printer.7")
Set oPrintJob = oPrinter.PrintJob
On Error Resume Next
' Convert to PDF.
Call oPrintJob.PrintOut(Server.MapPath("./input.doc"), Server.MapPath("./output.doc.pdf"))
If Err Then
Response.Write("<B>Failed!</B> " + Err.Description + "<BR>")
Response.Write("Conversion Result: " + oPrintJob.ConversionResultMessage + "<BR>")
Response.Write("Printer Result: " + oPrintJob.PrinterResultMessage + "<BR>")
Response.End
End If
Response.Write("<B>Success!</B><BR>")
%>
ASP Example 2 (VBScript):
<%@ Language=VBScript %>
<%
Option Explicit
Dim oLoader
Dim oPrinter
Dim oPrintJob
Dim arrPDF
' For ASP, instead of getting the Printer object directly,
' get it through the easyPDF SDK Loader object.
Set oLoader = Server.CreateObject("easyPDF.Loader.7")
Set oPrinter = oLoader.LoadObject("easyPDF.Printer.7")
Set oPrintJob = oPrinter.PrintJob
On Error Resume Next
' Get output PDF in memory (VT_ARRAY | VT_UI1).
arrPDF = oPrintJob.PrintOut2(Server.MapPath("./input.doc"))
If Err Then
Response.Write("<B>Failed!</B> " + Err.Description + "<BR>")
Response.Write("Conversion Result: " + oPrintJob.ConversionResultMessage + "<BR>")
Response.Write("Printer Result: " + oPrintJob.PrinterResultMessage + "<BR>")
Response.End
End If
On Error Goto 0
' Push the PDF file into browser.
Response.Clear
Response.ContentType = "application/pdf"
Response.AddHeader "Content-Disposition", "inline; filename=output.pdf"
Response.Buffer = True
Response.BinaryWrite arrPDF
Response.End
%>
ASP.NET Example (C# code snippet):
// You need to add easyPDF SDK COM objects into your application.
// From your project, go to "Project" -> "Add Reference..." menu
// to bring up the Add Reference dialog, click the COM tab, and
// then select all easyPDF SDK objects you will be using.
using BCL.easyPDF.Interop.easyPDFLoader;
using BCL.easyPDF.Interop.easyPDFPrinter;
// ...
Loader oLoader = null;
Printer oPrinter = null;
PrintJob oPrintJob = null;
try
{
// For ASP.NET, instead of getting the Printer object directly,
// get it through the easyPDF SDK Loader object.
Type type = Type.GetTypeFromProgID("easyPDF.Loader.7");
oLoader = (Loader)Activator.CreateInstance(type);
oPrinter = (Printer)oLoader.LoadObject("easyPDF.Printer.7");
oPrintJob = oPrinter.PrintJob;
// Convert to PDF.
oPrintJob.PrintOut(Server.MapPath("./input.doc"), Server.MapPath("./output.doc.pdf"));
Response.Write("<B>Success!</B>");
}
catch(System.Runtime.InteropServices.COMException err)
{
// Error handling code.
Response.Write("<B>Failed!</B> " + err.Message + "<BR>");
if(err.ErrorCode == (int)prnResult.PRN_R_CONVERSION_FAILED
&& oPrintJob != null)
{
Response.Write("Conversion Result: " + oPrintJob.ConversionResultMessage);
prnConversionResult result = oPrintJob.ConversionResult;
if(result == prnConversionResult.PRN_CR_CONVERSION
|| result == prnConversionResult.PRN_CR_CONVERSION_INIT
|| result == prnConversionResult.PRN_CR_CONVERSION_PRINT)
{
Response.Write("Printer Result: " + oPrintJob.PrinterResultMessage);
}
}
}