使用angularjs中web服务返回的pdf流在网页上显示pdf
当pdf作为流返回时,如何在angularjs的新选项卡上显示pdf fiddler捕获的pdf流标头为使用angularjs中web服务返回的pdf流在网页上显示pdf,angularjs,web-services,pdf,jsreport,Angularjs,Web Services,Pdf,Jsreport,当pdf作为流返回时,如何在angularjs的新选项卡上显示pdf fiddler捕获的pdf流标头为 HTTP/1.1 200 OK X-Powered-By: Express Access-Control-Allow-Origin: * Vary: Origin Connection: close Content-Type: application/pdf Content-Disposition: inline; filename="report.pdf" File-Extension:
HTTP/1.1 200 OK
X-Powered-By: Express
Access-Control-Allow-Origin: *
Vary: Origin
Connection: close
Content-Type: application/pdf
Content-Disposition: inline; filename="report.pdf"
File-Extension: pdf
Number-Of-Pages: 1
X-XSS-Protection: 0
Content-Length: 18126
AngularJS代码
externalService.getReport(template).then(function (data, error) {
if (data) {
type = 'application/pdf';
var newTab = $window.open('about:blank', '_blank');
newTab.document.write("<object width='400' height='400' data='" + data + "' type='" + type + "' ></object>");
}
}), function (error) {
if (error) {
}
}
externalService.getReport(模板)。然后(函数(数据,错误){
如果(数据){
类型='application/pdf';
var newTab=$window.open('about:blank','u blank');
newTab.document.write(“”);
}
}),函数(错误){
如果(错误){
}
}
好了:https://mozilla.github.io/pdf.js/examples/; 只需传入URL。我有一个来自web服务的流。它不是pdf文件的url。您是如何获得该流的?此外,如果您费心阅读API,它还可以与带有文件内容的预填充Uint8Array
一起使用。