Giter Site home page Giter Site logo

seapdfpreview's Introduction

SeaPDFPreview:预览PDF文件。

简介

   这个插件定义了一个全局对象cordova.plugins.seaPDFPreview,可以用来预览PDF文件。尽管这个对象在全局作用域中,但直到deviceready事件触发后,这个对象才能使用。

document.addEventListener("deviceready", onDeviceReady, false);
function onDeviceReady() {
    	console.log(cordova.plugins.seaPDFPreview);
}

安装方法

cordova plugin add cordova-plugin-sea-pdf-preview

打包事项

Android平台由于依赖第三方安装包,需在build.gradle文件中添加cdvBuildMultipleApks = true build.gradle

支持平台

  • Android
  • iOS

回调函数

  • 调用成功,返回json对象,有code、msg两个字段。
  • 调用失败,返回字符串。

本地预览PDF

   Android平台PDF文件存放在assets文件夹下,iOS平台文件存放在根目录下。

// assets/www/test.pdf
cordova.plugins.seaPDFPreview.preview(
    {
        type :"local",
        filePath : "www",
        fileName : "test"
		},
    function(data){
        
    },
    function(errorMsg){
        alert(errorMsg);
    }
);

在线预览PDF

cordova.plugins.seaPDFPreview.preview(
	{
		type : "online",
		filePath : "http://www.qq.com/abc.pdf"
	},
	function(data){
		myApp.alert(data.code+"---"+data.msg);
	},
	function(errorMsg){
		myApp.alert(errorMsg);
	}
);

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.