このサンプルでは、activePDF Toolkit の "インメモリ" 生成機能を使用します。次のスクリプトは、結果出力の PDF を作成するために、どのように "インメモリ" 入力ストリームを使用するかを説明します。
サンプル - インメモリの生成
'Instantiate Toolkit object
Set objTK = CreateObject("APToolkit.Object")
'Open output file varReturn = objTK.OpenOutputFile ("MEMORY")
If varReturn <> 0 Then Error("OpenoutputFile") End If
For i = 1 To 15 objTK.SetFont "Helvetica", 15 objTK.NewPage
Next
'Close the output file objTK.CloseOutputFile
'Write this output to a variable x = objTK.OutputByteStream r = objTK.OpenOutputFile("output.pdf")
'Retrieve the output bytestream objTK.InputByteStream = x r = objTK.OpenInputFile("MEMORY") objTK.SetHeaderTextColorCMYK 0, 100, 10, 0
'Let's load a font from disk objTK.SetHeaderFont "Verdana Bold Italic", 20 objTK.SetHeaderText 300, 600, "activePDF Toolkit"
'Copy Memory to the output file varReturn = objTK.CopyForm(0, 0)
If varReturn <> 1 Then Error("CopyForm") End If
'Close Output File objTK.CloseOutputFile
'Release Toolkit Object
Set objTK = Nothing
'Done Msgbox "Success!"
' Error Handling
Sub Error(Method) Msgbox "'" & Method & "' failed with a '" & varReturn & _ "'" & VBCRLF & "TK Return Codes:" & VBCRLF & _ "http://www.activepdf.com/support/kb/?id=10670&tk=ts" Set objTK = Nothing Wscript.Quit
End Sub
サンプル- ブラウザへのコンテンツ配信
このチュートリアルでは、Toolkit を使用して PDF 文書を "インメモリ" で生成し、ブラウザに配信します。
注意: このサンプル スクリプトは ASP で記述されています。
<%
'Tell ASP not to serve the page until entire page is processed
'Very Important
response.buffer = True
Set objTK = Server.CreateObject("APToolkit.Object")
'Tell Toolkit to create the PDF in memory
r = objTK.OpenOutputFile("MEMORY")
'SetFont will generate a new blank page and set the font to be used
'PrintText adds text to our new page