Skip to main content
Announcements
SYSTEM MAINTENANCE: Thurs., Sept. 19, 1 AM ET, Platform will be unavailable for approx. 60 minutes.
Francis_Kabinoff
Former Employee
Former Employee

A community user recently asked if there was any way to capture images of Qlik Sense objects in mashups and save to disk.  So the idea is, a user is using your mashup, makes some selections, finds some cool insights, and wants to save an image of the charts or objects in the mashup.


This is a bit tricky with the current browsers, but I've put together a solution that I've tested on newer versions of IE, Firefox, and Chrome, which works well. I'm going to attach it to this post, and walk you through using it.


The first thing you'll want to do is download the qBlob.zip file that's attached to this post. Then unzip it and place the qBlob folder in your mashup folder, which can be located at C:\Users\<username>\Documents\Qlik\Sense\Extensions\<mashup name> on Qlik Sense Desktop. If you are using Qlik Sense server, you will need to serve the files some way.


Then you'll need to include the qBlob.js in your mashup .js file, like so -

require_include.png



Once it's included, all you need to do to use it is call the following function, replacing <objId> with the ID of the container element of the Qlik Sense object, which you most likely also used in the app.getObject() method, and replace <output filename> with a filename you wish to output to. The filename requires a type, such as .png or .jpg.

qBlob.saveToFile(<objId>, <output filename>);

In the mashup I built to test the functionality, I attached the above function call to a click handler on an anchor element, like so -

$("a").click(function(e) {

   e.preventDefault();

   qBlob.saveToFile('QV01', 'mychart.jpg');

  });


You can take a look at this in action here - qBlob Test


I've attached my entire mashup folder that's linked to above, as well as just the qBlob folder that you'll need to do this in your own mashups.


44 Comments
Francis_Kabinoff
Former Employee
Former Employee

yea no prob. hmm. i'd still bet it's a path issue, just not sure what. you getting any error in console?

0 Likes
2,754 Views
mmonfort
Creator
Creator

Hi Francis - as you can see I have the folder structure set up like this:

Screenshot 2016-08-17 09.05.42.png

and my JS code is like this:

require( ["js/qlik", "./qBlob/qBlob/qBlob.js",], function ( qlik, qBlob ) {

  qlik.setOnError( function ( error ) {

  alert( error.message );

  } );

So the pathway looks right to me.

When I try to load my app, I get my modified rain load animation and the structure of the site showing however the charts don't show

Screenshot 2016-08-17 09.09.32.png

When I remove the ./qBlob/qBlob/qBlob.js it works again.

0 Likes
2,754 Views
Francis_Kabinoff
Former Employee
Former Employee

Are the files loading? Check the network tab in chrome dev tools

2016-08-16 19_27_16-Qlik Sense_ Mashup.jpg

0 Likes
2,646 Views
mmonfort
Creator
Creator

Thanks Francis, I'm a html newbie so didn't know I could check the files loading.


I am getting this result:Screenshot 2016-08-17 09.56.36.png

0 Likes
2,646 Views
Francis_Kabinoff
Former Employee
Former Employee

cool no problem. so you're getting 404, that's file not found. that means it is a path problem as we suspected. we need to see what path it's trying to load from, the easiest place is the console, which is also in dev tools. see my screenshot below. once we know what path its trying to load from, we can compare that to the path the file is actually at, and figure out how we need to adjust. check out the screenshot below, try to find your console and find a similar error message to what my mouse pointer is pointing at. i'm signing off for the night but i'll get back to any responses in the morning.

2016-08-16 20_12_20-Qlik Sense_ Mashup.jpg

0 Likes
2,646 Views
mmonfort
Creator
Creator

It's coming through here: Screenshot 2016-08-17 10.17.38.png

0 Likes
2,646 Views
Francis_Kabinoff
Former Employee
Former Employee

Nice job. you were doing it right, the path is correct, but i see now why it's not finding it. the repository simply isn't serving the files. Looks like we can't just drop files into the repository folder and expect them to be served.

Just add a file to your mashup from the dev-hub, and copy and paste the code from the qBlob.min.js file I just attached to the blog post into your new file. Name it whatever you like, and then load that with require. That make sense?

2,646 Views
mmonfort
Creator
Creator

Thanks Francis!

I got it working now:

Screenshot 2016-08-17 13.24.40.png

But when I click on the save image option the colours are gray in the background - am sure it's something I could just tweak in your .js file:

Screenshot 2016-08-17 13.26.29.png

anyway I will keep playing but this was a big step! Thanks for your help and for staying up late to do so

0 Likes
2,646 Views
mmonfort
Creator
Creator

Francis, sorry to bombard you with comments but this solution is great. The only thing I need to figure out is how to set the background color to be white when I save it as a PNG.

I un-minified your .js code and found the code for ..... backgroundColor").isTransparent() ...

I was not sure what to change it to though - I saw a whole heap of color variables further down but not sure how to use this in the background color code. Could you please advise?

Thanks again for your help!

0 Likes
2,692 Views
Francis_Kabinoff
Former Employee
Former Employee

Hmm that's interesting...I don't think you should need to change anything in the code to change the background color, it should pick up the background of the element you pass in. Try setting the background color of the element you pass in to white.

0 Likes
2,692 Views