Search code examples
javascriptangularjspdfviewer

Pdf viewer for my angular app


Is there any pdf viewer component for to see pdf in my angular app. I am tried angular-pdfjs-viewer but it does not work well. I have only a link to pdf file in server.

Thanks in advance


Solution

  • You can display the pdf using an iframe inside your application, have the url in a $scope variable as below

    $scope.yourURL = "pdfUrl";

    Then

    <iframe src="{{yourURL | trustAsResourceUrl}}"></iframe>
    

    Also you need to use the above filter.

    .filter('trustAsResourceUrl', ['$sce', function($sce) {
        return function(val) {
            return $sce.trustAsResourceUrl(val);
        };
    }])