Marione97 Posted May 18, 2022 Posted May 18, 2022 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); };
andy_b Posted May 18, 2022 Posted May 18, 2022 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.
Marione97 Posted May 18, 2022 Author Posted May 18, 2022 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
andy_b Posted May 18, 2022 Posted May 18, 2022 Something like: function printJobHook(inputs, actions) { if (inputs.job.jobSourceName == "The machine name of the client workstation") { actions.job.convertToGrayscale() } }
Marione97 Posted May 20, 2022 Author Posted May 20, 2022 Hi, i tried to insert the script but it doesn't work on Papercut, the prints from that server sent in color come out like this
PaperCutterBrenda Posted May 20, 2022 Posted May 20, 2022 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!
Marione97 Posted May 23, 2022 Author Posted May 23, 2022 Hi, I'm not understanding ... what should I do to convert the prints arriving from the SRV0010 from color to grayscale?
Marione97 Posted May 23, 2022 Author Posted May 23, 2022 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() } }
Steve21 Posted May 23, 2022 Posted May 23, 2022 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 Try without that Steve
Marione97 Posted May 23, 2022 Author Posted May 23, 2022 Hi,I corrected the error but it doesn't work
andy_b Posted May 23, 2022 Posted May 23, 2022 I think you need to provide more information, we really don't have a lot to work with here. I tested the script and it seems to work and converts jobs submitted by a client specified. Are you submitting the job from the Server, i.e the server is client? Do you have the machine name correct? Checked here for help? https://www.papercut.com/support/resources/manuals/ng-mf/common/topics/script-create-tips.html
Marione97 Posted May 23, 2022 Author Posted May 23, 2022 Hi, thanks for your support, i was able to convert the print from Grayscale through Ip Address.
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now