Server 2009

Automate Printing with PowerPoint

Example code is for an older version of Server, newer code is available.
<!-- Copyright (c) 2019 ActivePDF, Inc. -->
<!-- ActivePDF Server 2009 -->
<!-- Example generated 09/21/19  -->

<%
Dim strPath, intStartPrinting, intWait

strPath = Server.MapPath(".") & "\"

' Instantiate Object
Set oSVR = Server.CreateObject("APServer.Object")

' Path and filename of output
oSVR.OutputDirectory = strPath
oSVR.NewDocumentName = "Output.pdf"

' Start the print job
intStartPrinting = oSVR.StartPrinting()
If intStartPrinting <> 0 Then
  ErrorHandler "StartPrinting", intStartPrinting
End If

' Automate PowerPoint to print a document to activePDF Server
Set objPPT = Server.CreateObject("PowerPoint.Application")
Set objDoc = objPPT.Presentations.Open(strPath & "PPT.ppt", -1, 0, 0)
Set objOptions = objDoc.PrintOptions
objOptions.ActivePrinter = oSVR.NewPrinterName
objOptions.PrintInBackground = 0
objDoc.PrintOut 1, 9999, "", 1, 0
objDoc.Saved = 1
objDoc.Close
objPPT.Quit
Set objOptions = Nothing
Set objDoc = Nothing
Set objPPT = Nothing

' Wait(seconds) for job to complete
intWait = oSVR.Wait(30)
If intWait <> 0 Then
  ErrorHandler "Wait", intWait
End If

' Release Object
Set oSVR = Nothing

' Process Complete
Response.Write "Done!"

' Error Handling
Sub ErrorHandler(method, outputCode)
  Response.Write("Error in " & method & ": " & outputCode)
End Sub
%>

Copyright © 2019 ActivePDF, Inc