npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

capacitor-reader-plugin

v1.0.2

Published

document file reader

Downloads

251

Readme

capacitor-reader-plugin

文档阅读器( Document preview plugin)

支持平台

iOS&Android

支持的文档格式与技术说明

Android实现使用腾讯x5内核tbs,iOS借助于系统webview实现,
支持预览pdf,excel,ppt,doc,docx,txt等常见文档格式。

如何使用

  1. 安装插件
npm i capacitor-reader-plugin --save
npx cap sync
  1. Android capacitor工程配置

Android需要特殊设置下,ios无需特殊设置

  • APP AndroidManifest.xml 中添加TBS的Activity
        <activity
            android:name="com.library.fileviewer.tbs.TBSFileViewActivity"
            android:theme="@style/CustomActionBarTheme">

        </activity>
  • 工程build.gradle 设置ndk,加到defaultConfig中
android {
    compileSdkVersion 28
    defaultConfig {
        ndk {
            abiFilters "armeabi"
        }
    }
}
  • 在MainActivit中引入插件,并初始化x5内核

import android.os.Bundle;
import com.getcapacitor.BridgeActivity;
import com.getcapacitor.Plugin;

import java.util.ArrayList;
import com.reader.plugin.ReaderPlugin;

public class MainActivity extends BridgeActivity {
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    // Initializes the Bridge
    this.init(savedInstanceState, new ArrayList<Class<? extends Plugin>>() {{
      // Additional plugins you've installed go here
      add(ReaderPlugin.class);

    }});
    ReaderPlugin.initX5(getApplicationContext());   //初始化x5内核
  }
}

接口描述

openFile(options: { url: string,title:string,navbarColor:string }): Promise<any>;

url: 文档的链接如 https://test.abc/abc.pdf
title: 文档标题
navbarColor: 导航栏背景颜色,支持16进制格式颜色

使用示例

import 'capacitor-reader-plugin'
import { Plugins} from '@capacitor/core'
const { ReaderPlugin } = Plugins

// 打开文件阅读
function openFile(doc) {
    ReaderPlugin.openFile({ url: doc.url, title: doc.name, navbarColor: '#1989fa' })
}

注意事项

Android是借助于腾讯tbs来实现的,由于Google Play对于动态下发⼆进制代码的限制,
⽆法针对Google Play版本的app动态投放内核,所以需要上架Google Play的APP暂时⽆法使⽤X5内核,
如果您的Android应用是要在Google Play发布上架,请勿使用此插件。