Hello,
The share options in Dundas allows me to download the dashboard in excel, pdf format. I would like to know if it is possible to have a button or link that will run the report in PDF format in a new window in the browser.
Regards,
Sam
Hello,
The share options in Dundas allows me to download the dashboard in excel, pdf format. I would like to know if it is possible to have a button or link that will run the report in PDF format in a new window in the browser.
Regards,
Sam
To be able to view the PDF without first downloading it, you will have to have a PDF viewer embedded in your web server.
For example, you can download the PDFObject JavaScript library from https://github.com/pipwerks/PDFObject, embed it, and then call it through your override file [BIWebsite]Override\Html.Override.html
It will have the following format:
<script type=”text/javascript” src= "../libraries/ pdfobject.min.js "></script>
With that in place, the following code (based on the Create a PDF Export sample) generates the PDF and uses PDFObject.embed() to embed the PDF into the browser:
// Get the export service.
var exportService = this.getService('ExportService');
// Get the view service.
var viewService = this.getService('ViewService');
// Get the web app service.
var webAppService = this.getService('WebAppService');
// Get the dashboard or view id.
var dashboardId = this.parentView.id;
// add the following to get the current dashboard
var currentDashboardView = this.parentView.control;
var contextual = dundas.Utility.getContextualPageUrl(
dundas.Pages.DASHBOARD,
{
id: dashboardId,
queryString: [ new dundas.KeyValuePair(dundas.constants.VIEW_OPTIONS_QUERY_STRING_KEY, dundas.ViewOptions.VIEW_ONLY) ]
}
);
var shortLinkService = window.dundas.context.getService("ShortLinkService");
// Get the shortlink.
var shortLinkPromise = shortLinkService.getShortLink(contextual);
shortLinkPromise.done(
function(shortLink)
{
var fullLinkAddress = dundas.Utility.getContextualPageUrl(dundas.Pages.LINK, {
"queryString": [new dundas.KeyValuePair(dundas.constants.SHORT_LINK_QUERY_STRING_KEY, shortLink)]
});
// Create the export request.
var exportRequest =
new dundas.export.ExportRequest(
{
isLegacyExport: true,
// PDF provider id.
providerId: dundas.constants.STANDARD_PDF_EXPORT_PROVIDER_ID,
viewId: dashboardId
});
// export the current view
// add the following to get the current dashboard view.
exportRequest.viewData = currentDashboardView;
exportRequest.parameterValues.push(new dundas.data.SingleStringValue(
{
parameterId: dundas.export.PdfPropertyIds.ORIENTATION,
value: dundas.print.PaperOrientation.PORTRAIT
}
)
);
exportRequest.viewUrl = fullLinkAddress;
// Get the perform export promise.
var exportPromise =
exportService.performExport(exportRequest);
// Setup a loading dialog.
viewService.showLoadingRestCall(exportPromise);
exportPromise.done(
function(exportId)
{
// Get the Url for the export file.
var exportFileUrl =webAppService.getExportResultUrl(exportId);
PDFObject.embed(exportFileUrl);
}
);
}
);