Configure Devices and Printers with Advanced Printer Properties - PaperCutSoftware/PaperCutExamples GitHub Wiki

Using Device and Printer Properties for Advanced Configuration automation

Overview and introduction

server-command and the web services API allow you set and get properties for printers and devices.

For example

server-command get-printer-property print-server printer001 disabled
server-command set-printer-property print-server printer001 disabled true

and for devices (PaperCut MF only)

server-command get-printer-property device mfd-library advanced-config.ext-device.auth.pin-required-for-card
server-command set-printer-property device mfd-library disabled advanced-config.ext-device.auth.pin-required-for-card true

There are large number of properties that can be set to configure most (but not all) device and printer options.

IMPORTANT: The web services API (or server-command) will not validate the values you provide when setting properties. It is your responsibility to check they are correct and consistent.

Things that can be managed via the get/set printer properties interface include.

  1. Using Cost Models for printers and devices
  2. Printer Scripting, Watermarking, Printer Custom fields, user settings override, and many other printer settings. See Configuring Printer Changes
  3. Device setup, including authentication and release settings. See Configure Device Settings

Setting more than one property in a single API call.

As of PaperCut NG/MF 19.1, you can assign and retrieve multiple printer/device properties at a time (NOTE: through the web services API only).

Here is a python example:

import xmlrpc.client
from ssl import create_default_context, Purpose
import sys

host="http://localhost:9191/rpc/api/xmlrpc" # If not localhost then the client address will need to be whitelisted in PaperCut

auth="password"  # Value defined in advanced config property "auth.webservices.auth-token". Should be random

proxy = xmlrpc.client.ServerProxy(host, verbose=False,
      context = create_default_context(Purpose.CLIENT_AUTH))

properties = [["advanced-config.watermark.enabled","Y"],
["advanced-config.WATERMARK.text", "TESTING FROM COMMAND LINE %user% at %date% "],
["advanced-config.watermark.font-size", "14"],
["advanced-config.watermark.gray-level", "DARK"],
["advanced-config.watermark.position", "CROSS"],
["advanced-config.watermark.position-overrride-x","650"],
["advanced-config.watermark.position-overrride-y","1500"],
["advanced-config.watermark.position-direction-x", "Y"],
["advanced-config.watermark.position-direction-y", "Y"]]

server = "prt-serv.papercutsoftware.com"
printer = "toshiba2505"

try:
    result = proxy.api.setPrinterProperties(auth, server, printer, properties);
    # result = proxy.api.getPrinterProperties(auth, server, printer, get_properties);
except xmlrpc.client.Fault as error:
    # Handle exceptions
    print("\ncalled get/set printer properties. Return fault is {}".format(error.faultString))
    sys.exit(1)
except xmlrpc.client.ProtocolError as error:
    print("\nA protocol error occurred\nURL: {}\nHTTP/HTTPS headers: {}\nError code: {}\nError message: {}".format(
        error.url, error.headers, error.errcode, error.errmsg))
    sys.exit(1)

print(result)
⚠️ **GitHub.com Fallback** ⚠️