Skip to content

Commit

Permalink
#913 html5 printing
Browse files Browse the repository at this point in the history
* send file-size-limit as 10
* process the send-file packet by base64 encoding the data and opening a new window with a data-uri
* this seems to be working on Chrome and Firefox but not IE, pdf.js doesn't work right in IE anyway...


git-svn-id: https://xpra.org/svn/Xpra/trunk@10436 3bb7dfac-3a0b-4e04-842a-767bc560f471
  • Loading branch information
joshiggins committed Aug 24, 2015
1 parent 07f7ffd commit 8a4e8ee
Showing 1 changed file with 24 additions and 2 deletions.
26 changes: 24 additions & 2 deletions src/html5/include/xpra_client.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,8 @@ function XpraClient(container) {
'sound-data': this._process_sound_data,
'clipboard-token': this._process_clipboard_token,
'set-clipboard-enabled': this._process_set_clipboard_enabled,
'clipboard-request': this._process_clipboard_request
'clipboard-request': this._process_clipboard_request,
'send-file': this._process_send_file,
};
// assign callback for window resize event
if (window.jQuery) {
Expand Down Expand Up @@ -667,6 +668,7 @@ XpraClient.prototype._make_hello = function() {
// printing
"file-transfer" : true,
"printing" : true,
"file-size-limit" : 10,
});
}

Expand Down Expand Up @@ -1082,4 +1084,24 @@ XpraClient.prototype._process_clipboard_request = function(packet, ctx) {
}

ctx.protocol.send(packet);
}
}

XpraClient.prototype._process_send_file = function(packet, ctx) {
var mimetype = packet[2];
var printit = packet[3];
var data = packet[6];

if(mimetype != "application/pdf") {
console.warn("Received unsupported print data: "+mimetype);
} else if (!printit) {
console.warn("Received non printed file data");
} else {
// do the printing!
console.log("got some data to print");
var b64data = btoa(uintToString(data));
window.open(
'data:application/pdf;base64,'+b64data,
'_blank'
);
}
}

0 comments on commit 8a4e8ee

Please sign in to comment.