how to show pdf file in ionic app with out download

后端 未结 1 1773
没有蜡笔的小新
没有蜡笔的小新 2020-11-30 15:39

Things i did :

  1. used inappbrowser
  2. used google doc
  3. used webview

so i have tried all these methods to show the pdf file in androi

相关标签:
1条回答
  • 2020-11-30 15:50

    You will need to use ng-pdfviewer.

    AngularJS PDF viewer directive using pdf.js.

    <button ng-click="prevPage()">&lt;</button>
    <button ng-click="nextPage()">&gt;</button>
    <br>
    <span>{{currentPage}}/{{totalPages}}</span>
    <br>
    <pdfviewer src="test.pdf" on-page-load='pageLoaded(page,total)' id="viewer"></pdfviewer>
    

    and in your AngularJS code:

    var app = angular.module('testApp', [ 'ngPDFViewer' ]);
    
    app.controller('TestCtrl', [ '$scope', 'PDFViewerService', function($scope, pdf) {
        $scope.viewer = pdf.Instance("viewer");
    
        $scope.nextPage = function() {
            $scope.viewer.nextPage();
        };
    
        $scope.prevPage = function() {
            $scope.viewer.prevPage();
        };
    
        $scope.pageLoaded = function(curPage, totalPages) {
            $scope.currentPage = curPage;
            $scope.totalPages = totalPages;
        };
    }]);
    
    0 讨论(0)
提交回复
热议问题