Print Scripting with Mobility Print
KB Home | Print Scripting with Mobility Print
Main.PrintScriptingwithMobility History
Hide minor edits - Show changes to output
!!Example Script v19.0
!!!Suppress the Account Selection Popup with Mobility Print
We have a new api [@isMobilityPrintJob@] which makes it simple to identify the mobility print jobs. 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.
[@
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
if (inputs.job.isMobilityPrintJob){
actions.job.chargeToPersonalAccount();
}
}
@]
!!Alternative method pre PaperCut v19.0
Prior to PaperCut v19.0, a couple of extra steps are needed to get you up and running. Below we explain the steps to take and provide a sample script to get you started.
!!!Suppress the Account Selection Popup with Mobility Print
Of course! It just takes one simple step to get this up and going before you can start
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 [[https://www.papercut.com/support/resources/manuals/ng-mf/common/topics/script.html|Print Scripting]] utility. Below we explain the steps to take and provide a sample script to get you started.
For more information about Mobility Print, check out the [[https://www.papercut.com/products/ng/mobility-print/manual/| Mobility Print Help Center]].
Use the example script below to automatically charge
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.
if (matchesAny(inputs.job.documentName,
if (!inputs.job.isAnalysisComplete) {
actions.job.chargeToPersonalAccount();
return;
}
// Automatically charge all Mobility Print jobs to a users personal account
if (matchesAny(inputs.job.documentName, MOBILITY)){
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;
}​
if
actions.job.chargeToPersonalAccount();
function printJobHook(inputs, actions) {
var MOBILITY = [ 'mp:ios', 'mp:macos', 'mp:windows', 'mp:chrome', 'mp:chrome'];
if (matchesAny(inputs.job.documentName, MOBILITY)){
// Automatically charge all Mobility Print jobs to a users personal account
actions.job.chargeToPersonalAccount();
return;
}
}
@]
''Categories:'' [[Category.MobilityPrint|+]]
!!Can you use the PaperCut Print Script API with Mobility Print?
Of course! It just takes one simple step to get this up and going before you can start scripting away. 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.
#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\”
#Open the file mobility-print-conf.toml in a text editor and add this line “EnableDocumentNamePrefix = true”.
#Save the document.
#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.
!!Automatically charge to Personal Account
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.
[@function printJobHook(inputs, actions) {
var MOBILITY = [ 'mp:ios', 'mp:macos', ‘mp:windows', ‘mp:chrome’, ‘mp:chrome'];
if (matchesAny(inputs.job.documentName, MOBILITY)){
// Automatically charge all Mobility Print jobs to a user's personal account
actions.job.chargeToPersonalAccount();
return;
} @]
!!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.
----
[-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 September 03, 2019, at 07:36 PM
Printable View | Article History | Edit Article