View PDF with Angularjs callback

Asked

Viewed 646 times

0

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

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

..

{{report}}

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

1 answer

0


I was able to display the report using editing that snippet to:

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

this way my return in PDF is displayed legibly.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.