1

Needed solution in Reactjs i want to download any component content as a pdf with all the css effect. need help to complete the downloadAsPdf function

import React from 'react'

function downloadAsPdf(component,filename) {
    // todo download the component as pdf with that specified filename
}

function Table() {
    return (
        <div>
            Ant content that i want to download as pdf
        </div>
    )
}

function App() {
    return (
        <div>
            <button onclick={downloadAsPdf(Table,"id.pdf")}>download table as PDF </button>
            <p> some other work...</p>
        </div>
    )
}
export default App
Prayas Agrawal
  • 151
  • 3
  • 9
  • Does this answer your question? [Generating a PDF file from React Components](https://stackoverflow.com/questions/44989119/generating-a-pdf-file-from-react-components) – Befeepilf Jul 06 '20 at 18:18
  • that solution has a bug like it is not able to draw img Tag into canvas or say pdf, – Prayas Agrawal Jul 07 '20 at 10:43
  • I just wrote up a tutorial about how to extract a React component as PDF. People can read it over here: https://www.robinwieruch.de/react-component-to-image – Robin Wieruch Sep 27 '21 at 20:36

0 Answers0