Quantcast
Channel: Microsoft Dynamics CRM Forum - Recent Threads
Viewing all articles
Browse latest Browse all 82002

calling SSRS to generate PDF is falling at the PDF generation method

$
0
0

Hi All,

The code to generate PDF from SSRS is allover the internet and it seems to work for most, but mine does not seem to work and fails at the method that encodes the output from the reporting sessions parameter this is retrieved. Please look at the below code

function encodePdf(responseSession) {

    //Create request object that will be called to convert the response in PDF base 64 string
    var retrieveEntityReq = new XMLHttpRequest();

     //Create query string that will be passed to Report Server to generate PDF version of report response.
    var pth = Xrm.Page.context.getClientUrl() + "/Reserved.ReportViewerWebControl.axd?ReportSession=" + responseSession[0] + "&Culture=1033&CultureOverrides=True&UICulture=1033&UICultureOverrides=True&ReportStack=1&ControlID=" + responseSession[1] + "&OpType=Export&FileName=Public&ContentDisposition=OnlyHtmlInline&Format=PDF";
    retrieveEntityReq.open("GET", pth, true);
    retrieveEntityReq.setRequestHeader("Accept", "*/*");
    retrieveEntityReq.responseType = "arraybuffer";
    retrieveEntityReq.onreadystatechange = function () {

        if (retrieveEntityReq.readyState == 4 && retrieveEntityReq.status == 200) {
            var binary = "";
            var bytes = new Uint8Array(this.response);

            for (var i = 0; i < bytes.byteLength; i++) {
                binary += String.fromCharCode(bytes[i]);
            }
            var base64PDFString  = btoa(binary);
            createNote(base64PDFString );
        }
    };
    //This statement sends the request for execution asynchronously. Callback function will be called on completion of the request.
    retrieveEntityReq.send();
}


:

And the response from the api call is below:

onabort: null
onerror: null
onload: null
onloadend: null
onloadstart: null
onprogress: null
onreadystatechange: ƒ ()
ontimeout: null
readyState: 1
response: null
responseText: (...)
responseType: "arraybuffer"
responseURL: ""
responseXML: (...)
status: 0
statusText: ""
timeout: 0
upload: XMLHttpRequestUpload {onloadstart: null, onprogress: null, onabort: null, onerror: null, onload: null, …}
withCredentials: false
_async: true
_headers: ["Accept"]
_url: "ephraiminc.crm11.dynamics.com/Reserved.ReportViewerWebControl.axd;
↵
↵
↵<html>
↵<head>
↵&Culture=1033&CultureOverrides=True&UICulture=1033&UICultureOverrides=True&ReportStack=1&ControlID= HTML>
↵
↵
↵<html>
↵<head>
↵<scr&OpType=Export&FileName=Public&ContentDisposition=OnlyHtmlInline&Format=PDF"
__proto__: XMLHttpRequest

even when i copy the url and paste it onthe address Bar, it fails. somewhen with better knowledge please help.

 I wll appreciate your input.

Cheers 


Viewing all articles
Browse latest Browse all 82002

Latest Images

Trending Articles



Latest Images