'use client'

import { useRef } from 'react'
import generatePDF, { usePDF } from 'react-to-pdf'

export default function PdfDownloadNew() {
  const { toPDF, targetRef } = usePDF({ filename: 'page.pdf' })
  const myTargetRef = useRef(null)

  return (
    <div>
      <button onClick={() => toPDF()}>Download PDF</button>
      <div ref={targetRef}>Content to be generated to PDF</div>
      <button onClick={() => generatePDF(myTargetRef, { filename: 'mypage.pdf' })}>Download PDF</button>
      <div ref={myTargetRef}>
        <h1>Hello</h1>
      </div>
    </div>
  )
}
