Giter Site home page Giter Site logo

teammaestro / pdf-viewer Goto Github PK

View Code? Open in Web Editor NEW
76.0 14.0 12.0 1.7 MB

PDF viewer web component built in StencilJS. Reusable in Angular, Ionic, React, Vue.JS, etc.

License: MIT License

TypeScript 90.54% HTML 5.82% JavaScript 1.02% SCSS 2.62%
stencil ionic angular pdf pdf-viewer stenciljs stenciljs-components reactjs

pdf-viewer's Introduction

Built With Stencil

Hive PDF Viewer

This web component allows you to add PDF rendering support to your web applications.

Features

  • Rendering PDFs on web (Angular, Ionic, React, Stencil, etc.)
  • Search
  • Fit to Page / Fit to Width
  • Side panel for quick thumbnail navigation

Installation

  • npm i @teamhive/pdf-viewer

Usage

<hive-pdf-viewer src="http://www.mydomain.com/example.pdf"></hive-pdf-viewer>

Somewhere in your project (e.g. main.ts):

import { defineCustomElements } from '@teamhive/pdf-viewer/dist/loader';
defineCustomElements(window);

Angular

Add viewer assets to angular.json assets block:

{
    "projects": {
        "app": {
            "architect": {
                "build": {
                    "options": {
                        "assets": [
                            {
                                "glob": "**/*",
                                "input": "node_modules/@teamhive/pdf-viewer/dist/pdf-viewer/pdf-viewer-assets",
                                "output": "pdf-viewer-assets"
                            }

Follow the Stencil JS Framework Integration guide for more info.

Properties

Property Default Description
src The PDF web address location (http, https)
page 1 The default page index.
enableToolbar true If the toolbar is available for display.
enableSideDrawer true If the side drawer UI (and button) is available for display.
enableSearch true If the document can be searched through. Hides the button when false.

Events

Event Description
linkClick(href: string) Emits the href clicked when it's not an internal document annotation.
pageChange(currentPage: number) Emits the current page number when the current page changes.

Contributors

Sean Bannigan Sean Perkins Justin True
Sean Bannigan Sean Perkins Justin True

pdf-viewer's People

Contributors

bbjdt2224 avatar justintrue avatar sbannigan avatar sean-perkins avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

pdf-viewer's Issues

t.resolve is not a function

I am trying to test the component in an ionic v3 app by following these instructions to set things up.

However I have the following error when opening a page with the hive-pdf-viewer on it.

TypeError: t.resolve is not a function
    at Object.setNativePromise (polyfills.js:3)
    at L.configurable.L.set (polyfills.js:3)
    at module.exports (hive-pdf-viewer.js:79796)
    at $export (hive-pdf-viewer.js:79858)
    at hive-pdf-viewer.js:80943 "http://localhost:8100/build/pdfviewer/hive-pdf-viewer.js"

image

The www directory looks like this with the pdfviewer files:
image

System info:

 @ionic/cli-utils  : 1.19.2
    ionic (Ionic CLI) : 3.20.0

global packages:

    cordova (Cordova CLI) : 8.0.0

local packages:

    @ionic/app-scripts : 3.1.9
    Cordova Platforms  : none
    Ionic Framework    : ionic-angular 3.9.2

System:

    Node : v8.11.3
    npm  : 6.3.0
    OS   : Windows 10

Pinch-zoom destroys whole Capacitor container

Hey Sean,

as discussed on Slack, here‘s the issue.

I‘m using the team hive PDF viewer. I think it uses an iFrame under the hood. When it is open my pure Stencil app can be pinch-zoomed. This affects the whole app container of Capacitor. Any idea how this can be prevented.

You said:
Capacitor should prevent the web view pinch to zoom. However we haven’t baked that into the component yet. It is on our roadmap in the next few months.

See attached video.

I think you can re-pro without a test case repo?
Let me know!

Thanks,
Matt

'hive-pdf-viewer' is not a known element:

[Angular]
'hive-pdf-viewer' is not a known element:

  1. If 'hive-pdf-viewer' is an Angular component, then verify that it is part of this module.
  2. If 'hive-pdf-viewer' is a Web Component then add 'CUSTOM_ELEMENTS_SCHEMA' to the '@NgModule.schemas' of this component to suppress this message.

ionic3 blank

not error,ionViewDidLoad load , page is blank

Unnecessary files in published package

Need to remove most of assets found in pdf-viewer/dist/pdf-viewer/pdfiv-ewer-assets/viewer/web.

This custom wrapped package doesn't use the base pdf.js:

  • Images
  • Locales
  • Fonts
  • Example compressed pdf

ES5 error in Capacitor 2.4.6/Stencil 2.0.3 environment

Hey guys,

upgraded an app that uses your pdf-viewer. On Android I'm getting this in the dev console:

viewer.html:1 Uncaught (in promise) 
UnknownErrorException {message: "The browser/environment lacks native support for c…ed`); please use an ES5-compatible build instead.", name: "UnknownErrorException", details: "Error: The browser/environment lacks native suppor…ed`); please use an ES5-compatible build instead."}
details: "Error: The browser/environment lacks native support for critical functionality used by the PDF.js library (e.g. `ReadableStream` and/or `Promise.allSettled`); please use an ES5-compatible build instead."
message: "The browser/environment lacks native support for critical functionality used by the PDF.js library (e.g. `ReadableStream` and/or `Promise.allSettled`); please use an ES5-compatible build instead."
name: "UnknownErrorException"
__proto__: Error

In the component it shows:
image

Continues to work on ios as it did on Android the last year with Capacitor 1.5.

Should I maybe add ES5 build to my output?

Do you support local files open?

Support for local files to open files like path: file:///D:/pdftest/HGH-18123.pdf
Support for local files to open files like path: file:///D:/pdftest/HGH-18123.pdf
  Is there any ionic3 integration support? I see ng2-pdf-viewer support but does not support the opening of local file files.

Feature request: custom button and custom handler

ie. Your app requires users to read and accept a PDF contract

  1. User accesses the contract page, bringing up the contract PDF with stencil-pdf-viewer
  2. In the PDF viewer, there is an additional, custom button (in this case, indicating that they are accepting the contract)
  3. When they click this button, it activates the custom handler set in the client (in this case, brings up an 'Are you sure modal?' and closes the PDF viewer upon acceptance, passing the view back to the original caller)

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.