I am facing a challenge while trying to incorporate a PDF file into my Angular.js website. The PDF is stored as a blob in a MySQL database and I want to display it as one of the partial views that appear on the main page when a link is clicked. Unfortunately, I haven't been able to find clear guidance on how to achieve this. Below is the code snippet from my controller and I also have a PHP script that retrieves the file from the database. Any assistance on this matter would be highly appreciated.
var about = angular.module('about', []);
app.controller('aboutController', function($scope, $http) {
$http.post('PHP/aboutSearch.php', {responseType: 'arraybuffer'})
.success(function(response){
var file= new Blob([response], {type: 'application/pdf'});
var fileURL = URL.createObjectURL(file);
$scope.content = $SCE.trustedAsResourceURL(fileURL);
});
});
<?php
$query = mysqli_query($con, "SELECT doc FROM tbl_docs WHERE id = 1");
$row = mysqli_fetch_array($query);
$content = $row['doc'];
header('content-type: application/pdf');
?>