-1
我怎樣才能在angularjs一個新的選項卡上顯示PDF時,PDF被返回作爲流返回。通過提琴手捕獲顯示PDF從Web服務在angularjs
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: 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) {
}
}
我有一個來自web服務的流。它不是pdf文件的網址。 –
你是如何得到這個流的? –
另外,如果您不習慣讀取API,它也可以使用帶有文件內容的預先填充的「Uint8Array」。 –