-1

当 pdf 作为流返回时,如何在 angularjs 的新选项卡上显示 pdf。

提琴手捕获的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) {

            }
        }
4

1 回答 1

1

你去吧:https://mozilla.github.io/pdf.js/examples/;只需传入 URL。

于 2015-11-14T09:32:46.763 回答