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

@pdf-tools/four-heights-pdf-web-viewer

v4.3.3

Published

JavaScript PDF Viewer

Downloads

1,231

Readme

PDF Web Viewer

PDF Web Viewer by Pdftools, Switzerland, is a JavaScript component for viewing and annotating PDFs.

  • High PDF rendering quality, high performance, low footprint (webassemblies)
  • Responsive UI with no external dependencies
  • Support for mobile devices
  • Creation and editing of PDF annotations
  • PDF form filling
  • Reading and writing of FDF files
  • A multitude of configuration options
  • Easy integration in many JavaScript frameworks
  • Easy evaluation without the necessity of a license key

See our online demo.

Installation

Install the package with:

npm i @pdf-tools/four-heights-pdf-web-viewer --save

Static Assets

PDF Web Viewer comes with static assets and resource files (web assemblies, JavaScript files, translation json files) contained in the packet's pdfwebviewer sub-directory. These need to be served with your application from a "base URL", an absolute or relative path which must be defined prior to loading PDF Web Viewer, e.g. in the HTML file as:

<script type="text/javascript">
  window.PDFTOOLS_FOURHEIGHTS_PDFVIEWING_BASEURL = './pdfwebviewer/'
</script>

After installing or updating ensure that all static assets are copied.

Manual copying in a shell is possible, but not recommended, because it is easily forgotten. E.g, if PDFTOOLS_FOURHEIGHTS_PDFVIEWING_BASEURL is defined as above and your main directory for static assets is static:

cp -R ./node_modules/@pdf-tools/four-heights-pdf-web-viewer/pdfwebviewer ./static

Instead of manual copying, we recommend to use a bundler which does the work for you on every build.

E.g: webpack:

const path = require('path')
const CopyWebpackPlugin = require('copy-webpack-plugin')

const pdfwebviewerDir = path.join(
  path.dirname(require.resolve('@pdf-tools/four-heights-pdf-web-viewer')),
  '../pdfwebviewer'
)

module.exports = {
  ...
  plugins: [
    new CopyWebpackPlugin({
      patterns: [
        {
          from: '**/*',
          to: 'pdfwebviewer', // Should match PDFTOOLS_FOURHEIGHTS_PDFVIEWING_BASEURL
          context: pdfwebviewerDir,
        }
      ],
    }),
  ],
}

E.g. for Angular in angular.json:

"projects": {
  "angular": {
    "architect": {
      "build": {
        "options": {
          "assets": [
            {
              "glob": "**/*",
              "input": "./node_modules/@pdf-tools/four-heights-pdf-web-viewer/pdfwebviewer",
              "output": "./pdfwebviewer"
            }
          ],
        },
      },
    }
  }
},

In the above, the value of "output" directory should match PDFTOOLS_FOURHEIGHTS_PDFVIEWING_BASEURL.

Basic usage

A simple web application that uses PDF Web Viewer is implemented as follows.

index.html:

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <script type="text/javascript">
      // path to the directory containing the static assets must be set before the viewer is loaded
      window.PDFTOOLS_FOURHEIGHTS_PDFVIEWING_BASEURL = './pdfwebviewer/'
    </script>
    <link rel="stylesheet" type="text/css" href="./pdfwebviewer/pdf-web-viewer.css" />
    <title>PDF Web Viewer</title>
  </head>
  <body>
    <!-- HTM element containing the PdfWebViewer. -->
    <div id="pdfviewer" style="height: 100vh; width: 100vw"></div>
  </body>
</html>

index.js:

import { PdfWebViewer } from '@pdf-tools/four-heights-pdf-web-viewer'

const element = document.getElementById('pdfviewer')
const license = '' // insert your license key here

// see the documentation for all available options
const options = {}

const pdfViewer = new PdfWebViewer(element, license, options)

Documentation

PDF Web Viewer is documented in more detail in the manual. This manual is also contained in the package in the doc sub-directory.

Furthermore, we have some basic examples on how to integrate PDF Web Viewer in Angular, React or plain JavaScript. Please contact us.

Licensing

PDF Web Viewer runs both with or without license. If no license is set a watermark will be applied by default. If you don't want a watermark to be applied, please get a free evaluation license. If you want to buy a productive license then request a tailored quote or contact [email protected].