Print Scripting with Mobility Print

KB Home   |   Print Scripting with Mobility Print

Can you use PaperCut’s Print Scripting with Mobility Print?

Of course! It just takes one simple step to get this up and going before you can start using Mobility Print in tandem with PaperCut’s versatile Print Scripting utility. Below we explain the steps to take and provide a sample script to get you started.

Enable the Document Name Prefix

Before starting, you will need to follow these steps so that PaperCut can identify which jobs are from Mobility Print.

  1. On your Mobility Print server, navigate to [app-directory]/PaperCut Mobility Print/data/config. In Windows, this path will be C:\Program Files (x86)\PaperCut Mobility Print\data\config\.
  2. Open the file mobility-print-conf.toml in a text editor and add this line EnableDocumentNamePrefix = true.
  3. Save the document.
  4. Finally restart the Mobility Print service for the changes to take effect.

Now any jobs submitted via Mobility Print the document name will be prefixed with (mp:<source>) where source is one of iOS, macOS, windows, android, chrome or unknown. Administrators can use this value in their scripts to extract client type.

Suppress the Account Selection Popup with Mobility Print

Use the example script below to automatically charge to the user’s personal account (instead of showing an account selection popup) when a job comes from any Mobility Print source. Remove 'mp:macOS' and 'mp:windows' if these devices are actually running the PaperCut Client.

function printJobHook(inputs, actions) {
  // Hold the job until analysis is complete 
  if (!inputs.job.isAnalysisComplete) { 
    actions.job.chargeToPersonalAccount();
    return;
  }
  // Automatically charge all Mobility Print jobs to a users personal account  
  var MOBILITY = [ 'mp:iOS', 'mp:macOS', 'mp:windows', 'mp:chrome', 'mp:android'];
  if (matchesAny(inputs.job.documentName, MOBILITY)){
    actions.job.chargeToPersonalAccount();
  } 
}
// Define the matchesAny function
function matchesAny(str, matchStrs, actions) { 
  if (str == null || matchStrs == null) { 
    return false; 
  } 
  for ( var i in matchStrs) { 
    if (str.match(matchStrs[i])) { 
      return true; 
    } 
  } 
  return false; 
}

Still have questions?

Let us know! We’re definitely happy to chat about what’s going on under the hood. Feel free to leave a comment below if you have any questions at all or visit our Support Portal for further assistance.

For more information about Mobility Print, check out the Mobility Print Help Center.


Categories: Mobility Print, Advanced Scripting (Print Scripting)


[-Keywords: Mobility Print, Print Scripting, Print Script API, Account Selection]

Comments

Share your findings and experience with other PaperCut users. Feel free to add comments and suggestions about this Knowledge Base article. Please don't use this for support requests.

Article last modified on November 16, 2018, at 07:03 AM
Printable View   |   Article History   |   Edit Article