I am grabbing a PDF file from an input html and trying to make it display using the HTML5 File API, i am able to console.log the file url but its not displaying in my iframe:
Here is my html:
<html ng-app="PDFReaderApp">
<head>
<title> Automatically get your GPA from submitting in your transcript pdf file </title>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.25/angular.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.25/angular-route.js"></script>
<script src="./pdf.js" ></script>
<script src="./app.js" ></script>
<script src="./controllers.js"></script>
<style>
iframe {
height: 500px;
width: 400px;
margin: 2em;
}
</style>
</head>
<body ng-controller="TranscriptReaderCtrl">
<input id="inputPDF" type="file" accept="application/pdf" onchange="angular.element(this).scope().getPDF(this.files)" />
<div id="display">
<iframe id="viewer" ng-src="{{fileUrl}}" ></iframe>
</div>
</body>
</html>
and my angularjs controller code:
function TranscriptReaderCtrl($http, $scope, $window, $sce) {
$scope.uploadedPDF = "";
$scope.fileUrl = "";
$scope.getPDF = function(files) {
var fileUrl = $window.URL.createObjectURL(files[0]);
console.log(fileUrl);
$scope.fileUrl = $sce.trustAsResourceUrl(fileUrl);
console.log($scope.fileUrl);
}
}