Hey Dinara,
thank you. That was was the missing piece. I got it to work now. In case others have similar uses cases here is my final script. It exports a non embedded report and also allows to pass view parameter values from dashboard to report before the export.
var reportService = this.getService('ReportService');
var reportPromise = reportService.getReportById('<your report id here>');
// Create paper Settings from size.
// https://www.dundas.com/support/api-docs/js/#API%20Reference/dundas/print/PaperSettings/Methods/fromPaperSize.html
var paperSettings = dundas.print.PaperSettings.fromPaperSize(dundas.print.PaperSize.A4);
paperSettings.marginBottom = 0;
paperSettings.marginTop = 0;
paperSettings.marginLeft = 0;
paperSettings.marginRight = 0;
// Set the PaperSettings orientation property,
// https://www.dundas.com/support/api-docs/js/#API%20Reference/dundas/print/PaperSettings/Properties/orientation.html
paperSettings.orientation = dundas.print.PaperOrientation.LANDSCAPE;
//get the dashboard view parameters (I wanted to pass a language to my report)
var parentView = this.parentView;
var languageParamD = parentView.control.getViewParameterByName("LanguageParam");
reportPromise.done(function(report){
//get the report view parameters
var languageParamR = report.viewParameters.filter(function(item){return item.name ==
'LanguageParam'})[0];
//set to new values
languageParamR.parameterValue = languageParamD.parameterValue;
// Create the PDF Options
// https://www.dundas.com/support/api-docs/js/#API%20Reference/dundas/export/ExportHelper/Methods/exportPDF.html
var pdfOptions =
{
appendDateToFileName: true,
overrideFileName: false,
openOnCompletion: true,
enableOverlay: true,
paperSettings: paperSettings,
view: report
};
// Export the PDF with the PDF options.
// https://www.dundas.com/support/api-docs/js/#API%20Reference/dundas/export/ExportHelper/Methods/exportPDF.html
dundas.export.ExportHelper.exportPDF(pdfOptions);
});