Qlik Community

Qlik Design Blog

All about product and Qlik solutions: scripting, data modeling, visual design, extensions, best practices, etc.

Employee
Employee

Export Data, Image and Pdf from Qlik Sense September 2018 Capability API

In every new Qlik Sense release, we see some cool additions and features that make our life easier. All of the major ones, are discussed here, https://community.qlik.com/blogs/qlikproductinnovation/2018/09/11/qlik-sense-september-2018-has-arri...‌, but for those that work a lot with the Capability Api, there are 3 very much desired and long expected features: exportData, exportImg and exportPdf. With these, you can export any embedded object from your mashup in the above formats. You can also customize them by passing the desired options.

 

Below are the links to the help files so you can experiment more.

 

ExportData

https://help.qlik.com/en-US/sense-developer/September2018/Subsystems/APIs/Content/Sense_ClientAPIs/C...

 

ExportImg

https://help.qlik.com/en-US/sense-developer/September2018/Subsystems/APIs/Content/Sense_ClientAPIs/C...

 

ExportPdf

https://help.qlik.com/en-US/sense-developer/September2018/Subsystems/APIs/Content/Sense_ClientAPIs/C...

 

You can view all of these in action by visiting the qdt-components webpage

React template with qdt-components

 

Best,

Yianni

31 Comments
ajaykakkar93
Contributor III

Hello Everyone,

i am facing a issue in November 2018,

i am not able to export as PDF or IMAGE, but i am able to export the data to excel i need to implement other export feature as well it will be great if you and others can help me on this issue.

exportPdf_exportImg_issue.PNG






Same error is coming for IMG also

My simple test code

 

var prefix = window.location.pathname.substr(0, window.location.pathname.toLowerCase().lastIndexOf("/extensions") + 1);
var config = {
	host: window.location.hostname,
	prefix: prefix,
	port: window.location.port,
	isSecure: window.location.protocol === "https:"
};
require.config({
	baseUrl: (config.isSecure ? "https://" : "http://") + config.host + (config.port ? ":" + config.port : "") + config.prefix + "resources"
});
require(["js/qlik"], function(qlik) {
	qlik.setOnError(function(error) {
		$('#popupText').append(error.message + "<br>");
		$('#popup').fadeIn(1000);
	});
	$("#closePopup").click(function() {
		$('#popup').hide();
	});
	//callbacks -- inserted here --
	//open apps -- inserted here --
	var app = qlik.openApp('APP-ID', config);
	//get objects -- inserted here --
	// test
	app.getObject('QV01', 'OBJID').then(function(visual) {
		//console.log(visual);
		$("#exportChart").show().click(function() {
			//Working Good
			/*
			visual.exportData().then(function(result) {
				console.log('Data download link: ', result);
			});
			*/
			//Not Working IMG
			/*
				var Imgsettings = {
					imageType: 'png',
					height: 200,
					width: 300
				};
				visual.exportImg(Imgsettings).then(function(result) {
					console.log('Image download link: ', result);
				});
			*/
			//Not Working PDF
			var Pdfsettings = {
				documentSize: "A4",
				aspectRatio: 2,
				orientation: "landscape"
			};
			visual.exportPdf(Pdfsettings).then(function(result) {
				console.log('Pdf download link: ', result);
			});
			console.log("Exporting");
		});
	});
	//create cubes and lists -- inserted here --
});

Can some one help me on this &  please if i am wrong please explain me what was wrong.

 

Regards,

Ajay Kakkar

0 Likes
81 Views