Hi Ralf,
I don’t think the Media-Files show up in the server like that.
You could create a temporary file and “copy” the contents
var file = plugins.file.createTempFile('test','.pdf')
file.setBytes(plugins.http.getMediaData("media:///test.pdf"),true)
var url = plugins.file.getUrlForRemoteFile(file)
pdfForm.elements.pdf_Viewer.documentURL = url;
(i didn’t test that, though, and I’m notoriously bad with files…)
We do it a bit differently, we have a form-variable on the pdf-form, which is bound to the dataProvider-property of the component. We use this method to display reports from Jasper Reports, since we get the data not as files but as bytes, so we avoid creating / handling / deleting temp-files on the server.
reportBytes = plugins.jasperPluginRMI.runReport(dataSourceOrFs, report.path + "/" + report.fileName, '', plugins.jasperPluginRMI.OUTPUT_FORMAT.PDF, report.reportParameters, localeString);
var pdfForm = forms['pdf_viewer'];
if (pdfForm) {
pdfForm.pdfData = reportBytes
var mainWindow = application.getActiveWindow();
scopes.svyCustomDialogs.showFormInDialog(pdfForm, 25, 25, mainWindow.getWidth() - 40, mainWindow.getHeight() - 100, 'Bericht', true, false)
}
The main downside is that we can’t set the filename this way.