首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >离子框架PdfViewer

离子框架PdfViewer
EN

Stack Overflow用户
提问于 2015-03-11 16:09:47
回答 5查看 15.7K关注 0票数 5

我想为手机开发pdf电子书应用程序。是否有用于离子框架的pdf查看器组件。我喜欢mozilla pdf.js。我需要离子项目的例子。

EN

回答 5

Stack Overflow用户

发布于 2015-03-11 22:31:23

你有没有尝试过angular模块ng-pdfviewer?因为angular在Ionic的引擎盖下工作。

票数 7
EN

Stack Overflow用户

发布于 2015-05-05 19:35:05

代码语言:javascript
复制
 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;
  };
  }]);

指令使用了上面的pdf.js文件,超文本标记语言如下:

代码语言:javascript
复制
<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>

使用ng-pdf应该可以解决您的问题。

票数 3
EN

Stack Overflow用户

发布于 2017-05-25 21:53:31

你有没有试过这个Phonegap插件https://github.com/ti8m/DocumentHandler

下面是我是如何使用它的。

代码语言:javascript
复制
 $scope.HandleDocumentPlugin = function () {
    if (DocumentViewer != null) {
        DocumentViewer.previewFileFromUrlOrPath(
            function () {
                console.log('success');
            }, function (error) {
                if (error == 53) {
                    console.log('No app that handles this file type.');
                    var alert = $ionicPopup.alert({
                        title: 'Alert!',
                        template: "There is no app installed that handles this file type."
                    });
                    alert.then(function (res) {

                    });
                }
            }, $scope.PDF_URL);
    }
    else if (DocumentHandler != null) {
        DocumentHandler.previewFileFromUrlOrPath(
           function () {
               console.log('success');
           }, function (error) {
               if (error == 53) {
                   console.log('No app that handles this file type.');
                   var alert = $ionicPopup.alert({
                       title: 'Alert!',
                       template: "There is no app installed that handles this file type."
                   });
                   alert.then(function (res) {

                   });
               }
           }, $scope.PDF_URL);
    }
    else {
        console.log("error");
    }
}
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/28981387

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档