Qlik Community

Qlik Server Side Extensions Discussions

Discussion Board for collaboration on Server-Side Extensions and Advanced Analytics Integration.

Highlighted
ajaykakkar93
Contributor III

Error in exporting chart to Image or PDF using Qlik Sense API

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

Regards & Thanks,
Ajay Kakkar
ajaykakkar93@gmail.com
1 Solution

Accepted Solutions
gamaltawaf
New Contributor II

Re: Error in exporting chart to Image or PDF using Qlik Sense API

Hello Ajay,

   I found a solution for this. So the issue is you need to ask the visulatisation api to get the object take a look at code below.

  

var app = qlik.openApp('app-id');
app.visualization.get('object-id').then( function(vis) { 
   vis.exportPdf().then(function (result) {
        console.log('PDF download link: ', result);
    }); 
});
4 Replies
gamaltawaf
New Contributor II

Re: Error in exporting chart to Image or PDF using Qlik Sense API

I am facing the same issue.

Thanks Ajay for Explaining it in plenty of details.

 

Can anyone help with this?

 

Thanks 

gamaltawaf
New Contributor II

Re: Error in exporting chart to Image or PDF using Qlik Sense API

Hello Ajay,

   I found a solution for this. So the issue is you need to ask the visulatisation api to get the object take a look at code below.

  

var app = qlik.openApp('app-id');
app.visualization.get('object-id').then( function(vis) { 
   vis.exportPdf().then(function (result) {
        console.log('PDF download link: ', result);
    }); 
});
ajaykakkar93
Contributor III

Re: Error in exporting chart to Image or PDF using Qlik Sense API

1221.PNG512.PNG
Still getting this error

Regards & Thanks,
Ajay Kakkar
ajaykakkar93@gmail.com
gamaltawaf
New Contributor II

Re: Error in exporting chart to Image or PDF using Qlik Sense API

This seems to have to do with your access origin. 

Sorry, I can't help with that.