GeoEnrichment Service - Create Report

05-28-2014 12:33 PM
New Contributor III
I am working with the Create Report functionality of the GeoEnrichment service and I have run into an issue I'm not sure how to solve.  I can make the request to create the report using the esri.request class.  I am successful in submitting and generating the a pdf report, however I'm not sure how to display the pdf.  The result is a report is encoded as a binary byte-stream.

The result of the CreateReport method is a binary byte-stream where the PDF or Excel report are returned directly. The calling application will have to handle the response and present and/or save the binary output.

Does anyone know or can point me in the right direction as to how I can display this pdf in a browser window. I have been unable to locate any documentation in any of the Esri help for the GeoEnrichment or JavaScript API.
0 Kudos
2 Replies
Occasional Contributor

Identify the latest downloaded file from the downloads folder and then open in a browser by using method in Javascript..

Srikanth Dasari

0 Kudos
New Contributor II

Alternatively, you can use the blob type with your esriRequest like this (it will download the file and the user can click to open in browser):

    handleAs: 'blob',
    content: myArgs,
    url: ''
}).then(function(response) {
    if (response instanceof Blob) {
        var blob = new Blob([response], { type: 'application/pdf' });
        if (navigator.msSaveBlob) { // IE 10+
            navigator.msSaveBlob(blob, 'myfile.pdf');
        } else {
            var link = document.createElement("a");
            var url = URL.createObjectURL(blob);
            link.setAttribute("href", url);
            if ( !== undefined) { // feature detection
                // Browsers that support HTML5 download attribute
                link.setAttribute("download", this.fileName);
   = "visibility:hidden";