Skip to main content
Announcements
Join us at Qlik Connect for 3 magical days of learning, networking,and inspiration! REGISTER TODAY and save!
cancel
Showing results for 
Search instead for 
Did you mean: 
ajaykakkar93
Specialist III
Specialist 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

Please mark the correct replies as Solution. Regards, ARK
Profile| GitHub|YouTube|Extension|Mashup|Qlik API|Qlik NPrinting

1 Solution

Accepted Solutions
gamaltawaf
Contributor II
Contributor II

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);
    }); 
});

View solution in original post

5 Replies
gamaltawaf
Contributor II
Contributor II

I am facing the same issue.

Thanks Ajay for Explaining it in plenty of details.

 

Can anyone help with this?

 

Thanks 

gamaltawaf
Contributor II
Contributor II

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
Specialist III
Specialist III
Author

1221.PNG512.PNG
Still getting this error

Please mark the correct replies as Solution. Regards, ARK
Profile| GitHub|YouTube|Extension|Mashup|Qlik API|Qlik NPrinting

gamaltawaf
Contributor II
Contributor II

This seems to have to do with your access origin. 

Sorry, I can't help with that.

lambdaman
Contributor
Contributor

Hi,

I do manage to get a PDF export link, but the URL is not accessible. 

 

app.visualization.get('aYtxmq').then(function(vis){
  vis.exportPdf().then(function (result) {
    console.log('Image download link: ', result);
  });
});

 

 

This results in 

 

Image download link:  https://my-qlik.website.com:443/openproxy/tempcontent/50481ec5-4c17-4d53-ac36-6f7dfbc68b4f/fd6e31961187425bbb3bc3648e4988f6.pdf?serverNodeId=8372dd45-3070-4263-ad62-ca1926459c18

 

 

But when I open that URL I simply get the message 

The requested resource cannot be found.

Any idea what might be going wrong?

Please note that "https://my-qlik.website.com:443/openproxy" does indeed work and 'openproxy' is a virtual proxy set up with anonymous access that functions correctly.