Download report in PDF format Perspective

Hi guys,

I'm trying to download the report in PDF format with a button click in perspective.

In the gateway logs showing like the below:

Any idea what is wrong from my end?

log = system.util.getLogger('Complex Order Pdf Request')
	reportPath = "DashboardReport"
	reportParameters = {'StartDate':self.view.custom.bindings.selection.dtStartDate, 'EndDate':self.view.custom.bindings.selection.dtEndDate, 'historyEnable':self.view.custom.bindings.calculations.DashboardData.showHistory}
	today = system.date.now()
	fileDate = system.date.format(today, "yyyy-MM-dd")
	settings = {"path":"C:\\", "fileName":"Report_"+fileDate, "format":"pdf"}
	
	windowsUser = system.util.getProperty("user.name")
	log.info(windowsUser)
	log.info(system.util.getProperty("user.home"))
	system.report.executeAndDistribute(path = reportPath, project = "Test", parameters = reportParameters, action = "save", actionSettings = settings)

Thanks,
Priyanka

Don't use system.report.executeAndDistribute(). You need to use system.report.execute(), capturing the bytes it returns, and then use system.perspective.download().

2 Likes

Hi, following to this we have used system.report.execute() and system.perspective.download(). We were able to download report in downloads folder. But user wants it in specific folder, is there any way to achieve this?

Not from the Ignition side. The user has to tell their browser to not automatically use the downloads folder, but to ask every time. Then they can pick where to put the file, and substitute a different file name if they want. For security, this absolutely must involve the user.

(Controlling where and what name to use from the Ignition side would be something malware does, and if you did find a way, browser makers would quickly try to plug that security hole.)

1 Like

Got it. Thanks for your reply :smiley: