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

@evolutionjobs/pdf-viewer

v0.0.3

Published

PDF custom element viewer that supports regular expressions for term highlighting

Downloads

4

Readme

<pdf-viewer>

Lit based custom element PDF viewer that supports regular expressions for term highlighting.

The primary goal is quick viewing of CVs held as PDFs. We needed more powerful term highlighting, as most PDF viewers can only highlight simple terms. For instance when highlighting Java it should not include Javascript - we can do this with /\bjava\b/gim.

This uses https://github.com/mozilla/pdf.js to render canvas elements for each page, and adds the viewer with regular expression highlighting as a custom element.

Simple example:

<pdf-viewer src="..."></pdf-viewer>

How it works

There are 3 main parts:

  • <pdf-viewer-page> renders a single page and must be passed the PDF.js document proxy.
    • Each page renders with a <canvas> for the content and a transparent text overlay for highlighting.
  • <pdf-viewer-document> renders the document as a collection of pages. You can use this on its own and add your own UI.
    • @pdf-document-loading fires when the source has changed and loading is starting.
    • @pdf-document-loaded fires once the document has been successfully loaded (pages may still be rendering).
    • @pdf-document-error fires if an error is encountered while loading the document.
  • <pdf-viewer> wraps that in a Material Design UI similar to Chrome's own.
    • <plain-text> renders fallback content if the PDF fails (this is a requirement for us as we get a lot of corrupt CVs).
    • slot: error renders the error if PDF can't be parsed.
    • slot: loader renders the loading <paper-spinner>.
    • slot: actions renders the action buttons to zoom/fit the current page.

CSS styles use the following variables:

  • --pdf-background, default: #888, content behind pages.
  • --pdf-paper, default: #fff, colour of each page (overriden by canvas content).
  • --pdf-colour-1, default: #f00, colour for 1st term highlight.
  • --pdf-colour-2, default: #0f0, colour for 2nd term highlight.
  • --pdf-colour-3, default: #00f, colour for 3rd term highlight.
  • --pdf-colour-4, default: #fd0, colour for 4th term highlight.
  • --pdf-colour-5, default: #0fd, colour for 5th term highlight.
  • --pdf-colour-6, default: #d0f, colour for 6th term highlight.
  • --pdf-colour-7, default: #df0, colour for 7th term highlight.
  • --pdf-colour-8, default: #0df, colour for 8th term highlight. (subsequent terms repeat)
  • --pdf-highlight-opacity, default .4, highlights appear over text with this opacity.