Spooler 2017

FormName

# Copyright (c) 2018 ActivePDF, Inc.
# ActivePDF Spooler 2017
# Example generated 12/12/18 

# Get current path
$invocation = (Get-Variable MyInvocation).Value
$strPath = (Split-Path $invocation.MyCommand.Path) + "\"

# Instantiate Object
$oSP = New-Object -ComObject APSpooler.Object

# Use the PrintJobProfile object to set specific printer settings
# for the print job if the default options are not what is needed.
$oPJP = $oSP.PrintJobProfile("SettingsOne")

$oPJP.BinSource = 15
$oPJP.Collate = $False
$oPJP.ColorMode = 2
$oPJP.DPI = 300
$oPJP.Duplex = 1
$oPJP.FormName = "SampleForm"
$oPJP.Nup = 0
$oPJP.Orientation = 1
$oPJP.PaperSize = 1
$oPJP.PrinterName = "Microsoft Print to PDF"
$oPJP.PrintOddEvenAll = 3
$oPJP.ProfileName = "SettingsOne"
$oPJP.Scaling = 1
$oPJP.CustomScaling = 95.0
$oPJP.TrueTypeOption = 3

# File specific settings
$oSP.Copies = 1
$oSP.PageRange = "1-2,4"
$oSP.PrintAnnotations = $True

# Print directly to a printer. Leave first parameter blank for default printer
$results = $oSP.PrintFileCustom(oPJP, $strPath + "5pageLI.pdf", "")
If ($results.Status -ne 0)
{
  ErrorHandler ("PrintFileCustom", $results), $results.Status
}

# Release Object
$oPJP = $null

# Release Object
$oSP = $null

# Process Complete
Write-Host "Done!"

# Error Handling
function ErrorHandler($method, $oResult, $errorStatus)
{
  Write-Host("Error with ${method}: ")
  Write-Host("$errorStatus")
  Write-Host("$oResult.details")
  Exit 1
}

Copyright © 2018 ActivePDF, Inc