Select the printer based on user from the input file

Select the printer based on user from the input file

In this article it is described how you can use InterFormNG2 to select the printer based on a user profile found in the input file, that was sent to InterFormNG2.

As a simple example we consider a node in the XML file found via this path: /root/user.

We want InterFormNG2 to merge the input file with a template and print the result on a printer, that is selected via a table as below:

User
Printer
Allan
PRT01
Brian
PRT02
Christine
PRT02
<Fallback printer for anyone else>
PRT03

The setup is, that for the 3 named users the printer on the right should be selected. If the user found is not any of those, then the fall back printer (PRT03 above) should be selected.

This can be setup with a translation file and the built-in function, ng:translation.

First we build a translation file as a simple UTF-8 encoded text file with this as the contents:

Allan=PRT01
Brian=PRT02
Christine=PRT02
*OTHERWISE*=PRT03

The special key value, *OTHERWISE* sets the value (PRT03) if a key for lookup is not found (i.e. we search for a user, that is not Allan, Brian or Christine).
This file can e.g. be created with Notepad or Notepad++. We save the save file as PrinterLookup.properties.

The extension, .properties is required and you should avoid any underscore in the file name.

Now this file is uploaded to the translation library, so we can refer to it in InterFormNG2:
This XPath function returns the printer to use for the user, Brian:
ng:translation('PrinterLookup','Brian','')
Which returns the value, PRT02. 

This function:
ng:translation('PrinterLookup','Mr.X','')
Returns PRT03 as 'Mr.X' is not found in the translation file.

You can e.g. verify this in a text element in a template.

For the implementation in the workflow we can now use this function in the workflow like below:


The workflow editor might warn about a non-existing printer (depending on the selected selected sample file in the workflow) like below:




    • Related Articles

    • To printer

      The shortcut output workflow component, To printer enables you to print out the current printable payload in the workflow onto a selected printer. If you simply want to merge and print, then you should consider the Print component. Before calling ...
    • Save a printer file

      For support cases it can sometimes be required, that you include a saved printer file, that is used by the Spool2XML module. This would normally be the converted (XML) printer file, which will make the printing application generate 'XML like' spooled ...
    • Input forms

      An important part of the module, Webforms are the input forms. The input forms are used by the Enrich by input form workflow component to change the contents of an XML file via an interactive form. The input forms is a special kind of template in ...
    • Use a database to move a spooled file or set output printer

      In this section there are some examples how you use a database in order to find the output queue and output queue library via a database lookup and use that information to either move the input spooled file and/or use this information to select the ...
    • Printer connection options

      The possible connection methods for printers are: System/OS Direct socket LPD protocol IPP protocol SMB Protocol Preview Remote print client System/OS If you want to print on a printer, that is configured on the operating system, then you can ...