当我单击该文件时,它具有pdf文件,该文件会在新选项卡中打开并在其中显示打印和取消选项,但是当我单击该pdf文件时,我需要下载该文件。
HTML:
<a ng-show="measurements.userData.ownPdf" href="/v1/user/getMyMeasurementsPDF/{{measurements.userData._id}}" target="_blank">
<i class="fa fa-file-pdf-o fs-20" aria-hidden="true"></i>
</a>
<!-- <a ng-show="!measurements.userData.ownPdf" href="#" ng-click="PDFDownload()"> Download</a> -->
<a ng-show="!measurements.userData.ownPdf" href="#" ng-click="drawPDF($index)">
<!--<a ng-show="!measurements.measurements.ownPdf" href="http://localhost:8080/?url=http://13.232.3.152:3000/newPdf" target="_blank">-->
<i class="fa fa-file-pdf-o fs-20" aria-hidden="true"></i>
</a>
JS:
$scope.drawPDF = function(index) {
var w = window.open();
var elements = document.getElementsByClassName(index)[0].innerHTML;
w.document.write(elements);
w.print();
w.close();
};
我需要用于下载该文件的代码