Jump to content

Recommended Posts

Posted

Hi, I need help, I have to write a javascript script that allows my company to convert color prints to black and white when they are launched only from one of our servers, only from that server should they automatically become black and white.

At the moment I only found this script that allows you to convert from color to B / W.

 

const img = document.getElementById("eeveelutions");

const canvas = document.getElementById("canvas");

const ctx = canvas.getContext("2d");

 

img.onload = function () {

img.crossOrigin = "anonymous";

ctx.drawImage(img, 0, 0);

const imgData = ctx.getImageData(0, 0, canvas.width, canvas.height);

for (i = 0; i < imgData.data.length; i += 4) {

let count = imgData.data[i] + imgData.data[i + 1] + imgData.data[i + 2];

let colour = 0;

if (count > 510) colour = 255;

else if (count > 255) colour = 127.5;

 

imgData.data[i] = colour;

imgData.data[i + 1] = colour;

imgData.data[i + 2] = colour;

imgData.data[i + 3] = 255;

}

ctx.putImageData(imgData, 0, 0);

};

Posted

It should be easier to do using the actions.job.convertToGrayscale() function of the papercut scripting (or other built in methods), have a look at the script snippets for examples.

 

But I don't really understand what "launched only from one of our servers" means.

Posted
Hi, I mean that we have this specific Vm where there is our management system, this VM is on a physical server, we would like all the prints sent from them to convert to black and white
Posted

Something like:

 

function printJobHook(inputs, actions) {

if (inputs.job.jobSourceName == "The machine name of the client workstation") {

actions.job.convertToGrayscale()

}

}

Posted
Hi there Marione97! PaperCutter Brenda here. I checked with our Supporties real quickly and they said if you want, you could use the inputs.job.clientMachineOrIP - this should be a good way of telling if the server is the one that submitted the job. Hope that helps!
Posted

I tried this script but the print result is in color from the SRV0010

 

function printJobHook(inputs, actions) {

if (iinputs.job.clientMachine == "SRV0010") {

actions.job.convertToGrayscale()

}

}

 

Posted
I tried this script but the print result is in color from the SRV0010

 

function printJobHook(inputs, actions) {

if (iinputs.job.clientMachine == "SRV0010") {

actions.job.convertToGrayscale()

}

}

 

 

You have an extra i in input :p Try without that

 

Steve

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now



×
×
  • Create New...