当前位置: 首页 > 软件库 > 程序开发 > >

ember-pdfjs

An Ember Addon for PDFJS
授权协议 MIT License
开发语言 JavaScript
所属分类 程序开发
软件类型 开源软件
地区 不详
投 递 者 穆单鹗
操作系统 跨平台
开源组织
适用人群 未知
 软件概览

Ember PDFJS Addon

Dev Dependencies

This addon will provide some useful components for viewing and interacting with PDF documents to your ember-cli project. This addon unites the Ember framework ecosystem and the PDFJS open source project by Mozilla.

Installation

Within your ember-cli project:

  • ember install ember-pdfjs

This will add a pdf-document component to your application.

Standalone Sample

Though this project is an addon type for including a component in your Ember project, you can also kick the tires on the component in a live sample with this project.

git clone git@github.com:mysterlune/ember-pdfjs.git
cd ember-pdfjs && npm install && bower install
ember serve

... and in typical Ember fashion, a development server will fire up on port 4200. Then, simply visit:

http://localhost:4200

... and take a look at the familar, lovely "tracemonkey" document.

Usage

In a template, just do:

{{pdf-document src=[model.src]}}

or

{{pdf-document src="/path/to/your.pdf"}}

[model.src] can be a Uint8Array, as PDFJS allows this as a source type for the ...getDocument() signature.

Password Protected PDF Support

The addon also allows for the registration of an Ember action handler for use when a PDF is password protected. In a templateyou would add an action closure:

{{pdf-document src=[model.src] onPassword=(action 'myPasswordAction')}}

The associated action handler would look something like the following:

import { PasswordResponses } from 'ember-pdfjs/components/pdf-document';

export default Ember.Controller.extend({
    actions: {
        'myPasswordAction': function(setPassword, reason) {
            // The reason value provides an indication of first prompt
            // versus incorrect password prompt
            let promptText = 'Enter the password to open this PDF file.';
            if (reason === PasswordResponses.INCORRECT_PASSWORD) {
                promptText = 'Invalid password. Please try again.';
            }

            // Prompt the user for their password in some application-specific way
            let password = promptUserForPassword(promptText);

            // Callback with the password received from the prompt
            setPassword(password);
        }
    }
});

The action receives two parameters:

  • setPassword - A callback function that is used to set the password received from the user
  • reason - The "reason" that the password is being requested. One of:
    • PasswordResponses.NEED_PASSWORD (First time prompt)
    • PasswordResponses.INCORRECT_PASSWORD (Re-prompt when previous password was incorrect)

Note on Security

You will get errors and it will not load if you try to link to something not hosted on your domain. You will need to update contentSecurityPolicy in your Ember project accordingly.

Checkout Ember Igniter for a how-to on updating contentSecurityPolicy for your app.

Caveats

The goals of this project are spelled out in Issues. If there are recommendations that you need for own project, likely they will benefit others.

Running Tests

  • ember test

Contributing

If you have an "ember-ish"/"pdf.js-ish" addon project in the works -- or don't think this project will work for your needs -- please let's try to pull this together into one solution.

The Ember Community maintains a fundamental precept of common solutions to common problems. Proliferating addon solutions is kinda bunk, from a community perspective.

Please contribute!

We confessed that we're not the only ones trying to climb the same mountain.

-- DHH, on the character of the Rails Community

 相关资料
  • Ember检查器是一个浏览器插件,用于调试Ember应用程序。 灰烬检查员包括以下主题 - S.No. 灰烬检查员方式和描述 1 安装Inspector 您可以安装Ember检查器来调试您的应用程序。 2 Object Inspector Ember检查器允许与Ember对象进行交互。 3 The View Tree 视图树提供应用程序的当前状态。 4 检查路由,数据选项卡和库信息 您可以看到检查

  • 英文原文: http://emberjs.com/guides/getting-ember/index/ Ember构建 Ember的发布管理团队针对Ember和Ember Data维护了不同的发布方法。 频道 最新的Ember和Ember Data的 Release,Beta 和 Canary 构建可以在这里找到。每一个频道都提供了一个开发版、最小化版和生产版。更多关于不同频道的信息可以查看博客

  • ember-emojione ember-emojione is your emoji solution for Ember, based on the EmojiOne project. EmojiOne version 2 is used, which is free to use for everyone (CC BY-SA 4.0), you're only required to giv

  • Ember 3D Ember 3D is an Ember addon for using Three.js - an easy to use, lightweight, javascript 3D library. It is designed to: Prescribe a solid file structure to Three.js code using ES6 modules. Ena

  • Ember Table An addon to support large data set and a number of features around table. Ember Table canhandle over 100,000 rows without any rendering or performance issues. Ember Table 3.x supports: Emb

  • vscode-ember This is the VSCode extension to use the Ember Language Server. Features All features currently only work in Ember-CLI apps that use classic structure and are a rough first draft with a lo

  • ember-headlessui This is a work-in-progress implementation of: https://github.com/tailwindlabs/headlessui A set of completely unstyled, fully accessible UI components for Ember.js, designed to integra

  • Ember Popper An Ember-centric wrapper around Popper.js. Currently an alpha in active development. See the dummy app for examples Compatibility Ember.js v3.12 or above Ember CLI v2.13 or above Node.js