View PDF with AngularJS callback

0

I have a function that returns me a PDF document generated by Jasper on the backend:

RestSrv.find(url, function (data) {
    $scope.report = data;
});

..

{{report}}

I played the return in the scopo and tried to display it, but it did not display the PDF in the new WEB page, it displayed the special characters of the document, summarizing, I do not know a way to display the PDF document for the user.     

asked by anonymous 05.01.2017 / 20:48

1 answer

0

I was able to view the report by editing that snippet for:

    $http.get(url, {responseType: 'arraybuffer'})
        .success(function (data) {
            var file = new Blob([data], {type: 'application/pdf'});
            var fileURL = URL.createObjectURL(file);
            window.open(fileURL);
        });

so my return in PDF is displayed legibly.

    
06.01.2017 / 21:02