重要!
プリンタオブジェクトを使用する場合、
easyPDF SDK ローダー
オブジェクトの設定をしていることを確認してください。
ASP セットアップ:

|
<!--
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
' ASP のため、プリンタオブジェクトを直接取得する代わりに、
' easyPDF SDK オーダーオブジェクトを通してプリンタオブジェクトを取得してください。
Set oLoader = Server.CreateObject("easyPDF.Loader.6")
Set oPrinter = oLoader.LoadObject("easyPDF.Printer.6")
Set oPrintJob = oPrinter.PrintJob
On Error Resume Next
' 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 例 2 (VBScript):
<%@ Language=VBScript %>
<%
Option Explicit
Dim oLoader
Dim oPrinter
Dim oPrintJob
Dim arrPDF
' ASP のため、プリンタオブジェクトを直接取得する代わりに、
' easyPDF SDK オーダーオブジェクトを通してプリンタオブジェクトを取得してください。
Set oLoader = Server.CreateObject("easyPDF.Loader.6")
Set oPrinter = oLoader.LoadObject("easyPDF.Printer.6")
Set oPrintJob = oPrinter.PrintJob
On Error Resume Next
' メモリ内の出力PDFを取得します。 (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
' PDFファイルをブラウザ内へプッシュします。
Response.Clear
Response.ContentType = "application/pdf"
Response.AddHeader "Content-Disposition", "inline; filename=output.pdf"
Response.Buffer = True
Response.BinaryWrite arrPDF
Response.End
%>
ASP.NET 例 (C# code snippet):
// easyPDF SDK COM オブジェクトをお手持ちのアプリケーションの中へ追加する必要があります。
// Add Reference ダイアログを取り出すために、
// プロジェクトから、"Project" -> "Add Reference..." メニューへ行きます。
// COM タブをクリックし、そして今から使用するであろう全てeasyPDF SDK オブジェクトを選択します。
using BCL.easyPDF.Interop.easyPDFLoader;
using BCL.easyPDF.Interop.easyPDFPrinter;
// ...
Loader oLoader = null;
Printer oPrinter = null;
PrintJob oPrintJob = null;
try
{
// ASP のため、プリンタオブジェクトを直接取得する代わりに、
// easyPDF SDK オーダーオブジェクトを通してプリンタオブジェクトを取得してください。
Type type = Type.GetTypeFromProgID("easyPDF.Loader.6");
oLoader = (Loader)Activator.CreateInstance(type);
oPrinter = (Printer)oLoader.LoadObject("easyPDF.Printer.6");
oPrintJob = oPrinter.PrintJob;
// PDFへ変換します。
oPrintJob.PrintOut(Server.MapPath("./input.doc"), Server.MapPath("./output.doc.pdf"));
Response.Write("<B>Success!</B>");
}
catch(System.Runtime.InteropServices.COMException err)
{
// エラーハンドリングコード
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);
}
}
}