W3C home > Mailing lists > Public > public-web-intents@w3.org > January 2012

Proposal for using web intents for a print intent

From: Dave Raggett <dsr@w3.org>
Date: Wed, 25 Jan 2012 11:40:25 +0000
Message-ID: <4F1FEA29.9000607@w3.org>
To: WebIntents <public-web-intents@w3.org>
Claes and I had a chance to chat face to face, and came up with the
following proposal for a print intent that uses the existing Web Intents
interface definition unchanged. The proposal makes use of the intent
data property to pass an object that the print intent knows how to use.
The print intent involves a session with a printer during which the web
page can receive notifications, track when print jobs have completed,
and cancel pending print jobs, etc.

This is inspired by the capabilities envisaged by the UPnP default
printer service template for a typical printer, see:


-----8< cut here-----

var intent = new Intent("http://webintents.org/print");

// set up the intent data property for the print intent
// this will be handled by the browser which would include
// support for communicating with printers over UPnP, etc.

intent.data = {

  // handle completion, paper jam, ...
  // has to be standard for this intent
  notify: function (data)
     // on paper jam, cancel job

     if (data.printerState == "mediajam" )
       // notify user
       alert("sorry the printer has a media jam");

       // and now cancel the pending print job

  // the print intent has succeeded
  success: function (data)

  // check why the print intent failed
  fail: function (data)


// now start the activity and redirect
// the onSuccess, and onFail functions
// to methods on the intent data object

  function (data) { intent.success(data); },
  function (data) { intent.fail(data); }

-----8< cut here-----

The browser would be responsible for implementing the print intent, and
would set methods on the intent data object to allow the web page to
invoke actions on the printer for cancelling a print job or starting a
new print job with specific printer options, e.g.

  // cancel pending print job

  // start a new print job to print data in color on A4 media
  intent.data.start_job(data, { media_size: "A4", "color" : true})

An open question is when the success call back defined with
startActivity() is called. My suggestion is that this should be intent
specific. For the print intent, it would make sense to call this
function when the browser has succeeded in establishing the session with
the printer.  This would then allow the web page script to invoke the
printer's start job action. If on the other hand, the callback is only
invoked when the session ends, we would need a different means to inform
the web page script when the session has been established.

The example could be expanded upon to allow the web page script to track
the job ID returned by the printer for each job. The web page could then
expose this in the web page UI as a means for the user to track when
each job has completed, and a means to cancel pending jobs.

Dave Raggett <dsr@w3.org> http://www.w3.org/People/Raggett
Received on Wednesday, 25 January 2012 11:40:57 UTC

This archive was generated by hypermail 2.3.1 : Tuesday, 6 January 2015 20:14:45 UTC