Skip to main content
Announcements
Have questions about Qlik Connect? Join us live on April 10th, at 11 AM ET: SIGN UP NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
briwilli
Contributor III
Contributor III

Export chart PDF

We have a web app that allows users to export line charts to PDF.  The export process utilizes the Vosialization API’s exportPDF() method. The problem we are having is that the image for longer charts is being clipped in order for it to fit in the PDF page.  Is there a way to scale the image smaller so that it can be embedded into the PDF without being clipped? Or is there another recommended way to do this?

 

thanks

Brian

Labels (2)
3 Replies
ForgotMyOldUsername
Contributor III
Contributor III

In the API, have you tried specifying 'fit to page' option?

ForgotMyOldUsername_0-1642207740820.png

 

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

 

 

briwilli
Contributor III
Contributor III
Author

Thanks for your response.  I am using the aspectRatio set to 2 as shown in the settings object defined below.  I've also experimented with using aspectRatio = 0 and setting the object size to a specific size but so far have not been able to get that setting to work at all, the resulting PDF image is empty - the settings I used for this test is shown commented out below.

var settings = { documentSize: "a4", aspectRatio: 2, orientation: "landscape" };
//var settings = { documentSize: "a4", aspectRatio: 0, orientation: "landscape", objectSize: "{height: 452, width: 1327}" };

Here is a screenshot of the chart that is initially displayed in the web page.  As you can see the chart displays years from 1958 through 2001 with additional years that can be viewed by scrolling the chart vertically.
briwilli_0-1642517754570.png


Below is a screen shot of the PDF file that is generated from the above chart using the aspectRatio of 2 setting with the exportPDF() method.  As you can see, the chart in the PDF is clipped so that it only shows years 1958 through 1975.   My goal is to have the PDF show the full set of years that are visible in the web page (1958 - 2001)

briwilli_1-1642517954818.png

Any additional help you can provide will be greatly appreciated.

Thanks
Brian

ForgotMyOldUsername
Contributor III
Contributor III

Hopefully someone else can chime in, I think it might just be the fixed nature of the QlikSense sheets. 

Although you can extend vertically,  you can't make a chart 'super-wide', so I think ( someone correct me )  what's happening is, the visualisation is scaling to a 'default' width, rather than what's specified in your chart when rendering for the PDF.

It's just as unpredictable and uncontrollable when doing stuff for NPrinting too.  

The only work around might be to have the axis as a true date axis, display as 'year' only, then have fewer label intervals.  It's a shame there's not more control in the chart object around this, like there is in Excel, where the data points in a chart and the label intervals don't need to match up.