0.3.2 • Published 2 years ago

react-paper-viewer v0.3.2

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

React Paper Viewer

$ yarn add react-paper-viewer
import { useRef } from 'react'
import { PaperViewer } from 'react-paper-viewer'
import type { PaperViewerToCanvas } from './components/PaperViewer'

function App() {
  const toCanvasRef = useRef<PaperViewerToCanvas>()
  const download = async () => {
    if (!toCanvasRef.current) return

    const canvas = await toCanvasRef.current()
    const dataURL = canvas.toDataURL()
    const a = document.createElement('a')
    a.download = 'sample.png'
    a.href = dataURL
    a.click()
  }

  return (
    <>
      <PaperViewer
        src="/src/logo.svg"
        onInit={({ toCanvas }) => {
          toCanvasRef.current = toCanvas
        }}
      />
      <button onClick={download}>Download</button>
    </>
  )
}

export default App
0.3.0

2 years ago

0.1.2

2 years ago

0.2.0

2 years ago

0.1.1

2 years ago

0.3.2

2 years ago

0.3.1

2 years ago

0.1.0

2 years ago