1.0.0 • Published 3 years ago

svelte-pdf-viewer v1.0.0

Weekly downloads
-
License
Apache-2.0
Repository
gitlab
Last release
3 years ago

This is a wrapper for pdf.js, that make it ease to use.

You can use this with svelte or vanilla js.

How to

npm install svelte-pdf-viewer

Svelte

<PdfViewer file={ myFileUrl } bind:infos={ pdfInfos }/>

<script>
	import PdfViewer from 'svelte-pdf-viewer'
	let pdfInfos
	const myFileUrl = ''
</script>

Vanilla

<div id="container">
</div>

<script>
	import PdfViewer from 'svelte-pdf-viewer'
	import 'svelte-pdf-viewer/dist/bundle.css'
    const myFileUrl = ''
    
    new PdfViewer({
        target: document.querySelector('#container'),
        props: {
            file: myFileUrl
        }
    })
</script>

Props

file: string - file url
infos: object - read only object with pdf viewer infos, only useful with svelte. 
    info.totalPages: number - total of pdf pages
    info.zoom: number - current zoom percent, min: 0.4, max 1.9
    info.currentPage: number - current page

Events

No one yet

1.0.0

3 years ago