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

ember-pdfjs2

v0.5.2

Published

A PDFJS Addon for Ember.

Downloads

5

Readme

Ember PDFJS Addon

Latest NPM release Downloads per month Total downloads Dependencies Dev Dependencies Issues Issues Ember Observer Score

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.

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 [email protected]: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 template you 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.

Installation

  • 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