Socket
Socket
Sign inDemoInstall

svelte-pdfjs

Package Overview
Dependencies
70
Maintainers
1
Versions
38
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    svelte-pdfjs

A wrapper around Mozilla's PDFJS renderer. Only cares about loading and showing the PDF and nothing else, all the fancy stuff such as styling the viewer is left up to the consumer. Still in early stages so feel free to create an issue or a PR for any bugs


Version published
Weekly downloads
131
decreased by-32.82%
Maintainers
1
Created
Weekly downloads
 

Changelog

Source

0.6.3

Patch Changes

  • feat: only render in ssr

Readme

Source

svelte-pdfjs

A wrapper around Mozilla's PDFJS renderer. Only cares about loading and showing the PDF and nothing else, all the fancy stuff such as styling the viewer is left up to the consumer. Still in early stages so feel free to create an issue or a PR for any bugs that you find, any improvements or feature requests.

Usage

You'll have to install pdfjs-dist and provide a worker to the Document component through svelte's context. For vite/sveltekit users a convenience function is exported through svelte-pdfjs/utils/vite which takes care of browser checks, resolving the url to the worker, setting the context and cleaning up when the component is destroyed.

See src/routes/+page.svelte and src/routes/+layout.svelte Demo

SSR

For now this package cannot be used with SSR, contributions to improve in that area are more than welcome. Because of how pdfjs-dist is packaged, there is an eval which prevents bundlers from properly minifying whatever chunk it ends up in. To get around it, you can patch your installation of pdfjs-dist such that all instances of _is_node.isNodeJs are replaced with false since those parts aren't going to be used anyway.

TODOs:

  • Text layer rendering
  • SvelteKit compatibility
  • SVG renderer
  • Annotation layer
  • Error handling
  • Expose more stuff

License

MIT

Keywords

FAQs

Last updated on 10 May 2023

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc