Find your dream job at PaperCut

Choose your language

Choose your login

Contact us

Help Center menu

PRODUCT MANUALS

PaperCut NG & PaperCut MF Manual

PRODUCTS FEATURED

Extract usernames in enterprise print environments (e.g. SAP, Unix)

It is common in an enterprise print environment using packages such as SAP, JD Edwards, Oracle Financials or Unix systems for print jobs (e.g. batch reports) to be displayed in print queues under a system account name rather than the instigating user’s account name. The result is that all jobs printed from these programs are recorded in the PaperCut NG/MF job log as owned by the program/system account.

In most environments, you can configure these programs or systems to write the username into the print spool file (PDL). For example, you can add the username as a PJL header. If this is done, then PaperCut NG/MF can extract the username and use it in place of the username supplied to the print queue.

The extraction process, when configured, applies the following rules:

  1. You can define multiple patterns to extract the username. The matching process returns the first valid result found.

  2. Username extraction at the current time is not supported on Novell.

  3. The username is included in the first megabyte of the spool file.

Configuring PaperCut to extract usernames from spool files

Username extraction from spool files is performed by the PaperCut Print Provider and as such any configuration text described in the following steps needs to be inserted into [app_path]\providers\print\win\print-provider.conf. After a change to the config is made, restart the Print Provider service before testing.

Extracting usernames using the simple method

The Simple Method uses prefix and suffix text as static bookends for the username that is extracted. In the below example (which you can copy and paste into your print-provider.conf), the user john.wayne is extracted from the string @PJL COMMENT SAP_USER="john.wayne". Simple Matching is sufficient in the majority of customer environments.

#
# Extract username from spool files coming from our enterprise system.
# Look for a header that matches @PJL COMMENT SAP_USER="john.wayne"
#
UsernameOverridePrefix=@PJL COMMENT SAP_USER="
UsernameOverrideSuffix="  

Extracting usernames using the advanced method (regular expressions)

The Advanced method adds powerful regular expression pattern plus the ability to define up to five of these patterns, labelled UsernameOverrideRegex1 to UsernameOverrideRegex5. Administrators using this method need to be familiar with regular expressions. The username is extracted from the first bracketed match group (e.g. $1).

In the example below two patterns are matched:

#
# Extract username from spool files coming from our enterprise system.
# Username may be defined in one of two formats:
# (john.wayne) XJXsetUserName
# /Author (john.wayne) def
#
UsernameOverrideRegex1=\((\S+?)\)\s*XJXsetUserName
UsernameOverrideRegex2=Author\s*\((\S+?)\)\s*def

The table below shows some further examples of username declarations seen in spool files and corresponding regular expressions that can extract the correct username.

Examples of usernames seen in spool files and regular expressions to extract them
Username in Spool FileRegular Expression to Extract Username
@PJL SET USERNAME="john.wayne"@PJL\s+SET\s+USERNAME\s*=\s*"(\S+?)"
@PJL SET USERNAMEW="john.wayne"@PJL\s+SET\s+USERNAMEW\s*=\s*"(\S+?)"
@PJL XJAUSERNAME = "john.wayne"@PJL\s+XJAUSERNAME\s*=\s*"(\S+?)"
@PJL COMMENT "Username: john.wayne"@PJL\s+COMMENT\s+"Username\s*:\s*(\S+?)"
@PJL COMMENT CANPJL SET USERNAME="john.wayne"@PJL\s+COMMENT\s+CANPJL\s+SET\s+USERNAME\s*=\s*"(\S+?)"
@PJL COMMENT "Username: john.wayne;App FileName: True Grit.doc"@PJL\s+COMMENT\s*"Username\s*:\s*(\S+?)\s*;
@PJL OKIAUXJOBINFO DATA="UserName=john.wayne"@PJL\s+OKIAUXJOBINFO\s+DATA\s*=\s*"UserName\s*=\s*(\S+?)\s*"
%%For: john.wayne%%For:\s*\(?([\w\.-=]+?)\)?\b
/USERNAME (john.wayne) def/USERNAME\s*\((\S+?)\)\s*def
/UserName (john.wayne) def/UserName\s*\((\S+?)\)\s*def
/Author (john.wayne) def/Author\s*\((\S+?)\)\s*def
(john.wayne) /RRCustomProcs /ProcSet findresource begin logusername end\((\S+?)\)\s*/RRCustomProcs\s*/ProcSet\s+findresource\s+begin\s+logusername
(john.wayne) XJXsetUserName\((\S+?)\)\s*XJXsetUserName

Comments