I am returning a byte[] of PDF content as JSON response from REST API, and trying to render the data in angular JS.
here is my JS code snippet :
if(data.appStatusCode===0){
var jsonObj = JSON.parse(data.payload);
var reportData = jsonObj.data;
var file = new Blob([reportData], {type: 'application/pdf'});
var fileURL = URL.createObjectURL(file);
window.open(fileURL);
}
and the controller which returns byte[] as payload
@RequestMapping(value = "/janitramwebreport/{janitramid}",
method = RequestMethod.GET,
produces = Constants.APPLICATION_JSON_VALUE)
public ResponseEntity<ResponseVO> getReportWebPdf(HttpEntity<?> httpEntity) {
*//returns byte[] as the payload*
}
when I try to generate PDF in a new window, I get PDF file error message.
Did you look at:
AngularJS: Display blob (.pdf) in an angular app
AngularJS Display PDF (byte[]) received from Spring @RestController
I think this has been answered already.
In the following link, you should find the answer :
AngularJS Display PDF (byte[]) received from Spring(@RestController) + jasper report
In this link you find how display pdf in a iframe using angularjs. The pdf is received from a API rest using spring and jasper report.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.