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 6 Type Library"
UUID="{3E8253B7-B37A-4926-B807-2426E3ACB90E}"
VERSION="6.0"
-->
<!--
METADATA TYPE="TypeLib"
NAME="BCL easyPDF PDF Processor SDK 6 Type Library"
UUID="{E1A2691E-2081-4b19-B89A-BB8CF680E991}"
VERSION="6.0"
-->
<!--
METADATA TYPE="TypeLib"
NAME="BCL easyPDF PDF Converter SDK 6 Type Library"
UUID="{32CD0069-0F92-4e45-AB0E-D6A0E6167C1F}"
VERSION="6.0"
-->
<!--
METADATA TYPE="TypeLib"
NAME="BCL easyPDF PDF Document SDK 6 Type Library"
UUID="{4CF55C9B-CF47-4766-99EC-F7B6B0BB8926}"
VERSION="6.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.6")
Set oPrinter = oLoader.LoadObject("easyPDF.Printer.6")
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.6")
Set oPrinter = oLoader.LoadObject("easyPDF.Printer.6")
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.6");
oLoader = (Loader)Activator.CreateInstance(type);
oPrinter = (Printer)oLoader.LoadObject("easyPDF.Printer.6");
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);
}
}
}