qlik-oss / picasso.js

A charting library streamlined for building interactive visualizations for the Qlik product suites.
https://qlik.dev/libraries-and-tools/picassojs
MIT License
188 stars 55 forks source link

Export picasso visualization as image or pdf #425

Closed hill84 closed 5 years ago

hill84 commented 5 years ago

Hi everybody! 👋 I want to export a custom chart visualization I created with Picasso.js in a Qlik sense mashup (created with React.js) as Pdf or image. I've been able to set a function to export the same chart as data (.xlsx), but when I try to export it as image or Pdf I receive an "Internal Server Error" (on server) or a "Blocked by CORS warning" (on localhost). The same functions work well with embedded Sense visualizations.

I am using the exportPdf and exportImg methods of the Visualization API.

My issue seams the same as this topic in the Qlik Community Forum.

What am I doing wrong? 😭

My function:

qApp.visualization.get(objectId).then(qViz => {
  qViz.exportPdf(settings).then(res => {
    this.downloadURI(res, fileName);
  }).catch(err => console.log(err)); // ERROR
}).catch(err => console.log(err));

The server error:

POST https://40.113.14.238/printing/export/object/pdf?requestId=957dc6b8-3e3b-4fdd-94c8-ae3dddc87411 500

The local error:

Access to XMLHttpRequest at 'http://localhost:9073/printing/export/object/image?requestId=61981b8a-d45b-4dfb-a622-e1f19dd65027' from origin 'http://localhost:3000' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: The value of the 'Access-Control-Allow-Origin' header in the response must not be the wildcard '*' when the request's credentials mode is 'include'. The credentials mode of requests initiated by the XMLHttpRequest is controlled by the withCredentials attribute.

My mashup config:

"DESKTOP": {
    host: 'localhost',
    secure: false,
    port: 4848,
    prefix: '',
    appId: 'appname.qvf'
  }
miralemd commented 5 years ago

Hi @hill84,

Exporting and Visualization API in Qlik is not managed by picasso, you might wanna try https://community.qlik.com/t5/Qlik-Sense-Integration/bd-p/qlik-sense-integration-extension-api