Search code examples
javascriptcross-domainipp-protocol

Is it possible to send an ipp print job from the browser?


Is it possible to send an IPP Print request from the browser using ajax?

I assume it would look something like this:

// Data to be sent
var data = "Testing\nTesting\n1\n2\n3";

// Jquery AJAX call
$.ajax("ipp://<printerip>:631", {
    'type': 'POST',
    'data': data,
    'complete': function(jqXHR, textStatus){
        alert('Result:'+textStatus)
    }
}); 

The only problem is I get:

XMLHttpRequest cannot load ipp://<printerip>:631. 
Cross origin requests are only supported for HTTP.

Is there anyway to get around this? Or is this simply impossible?


Solution

    • The only thing AJAX and IPP have in common is HTTP
    • IPP messages are byte-encoded not XML- or JSON-encoded
    • You'd need to convert XML/JSON to proper IPP (honestly: doesn't make sense)
    • The IPP server should support CORS to avoid awkward workarounds

    There's a pure JavaScript IPP implementation available at https://www.npmjs.com/package/ipp (not sure if it runs in browsers)

    Answer: It's not possible to send an IPP request using ajax.