0

I have my own component that uses andt I want to select some object in a table and pass it to my component and download it as a pdf.

I tried wrapping my component but nothing happened just my text was gone

const DocumentForPrint = ({ children }) => {
  return (
    <Document>
    <Page size="A4">
        { children }
    </Page>
  </Document>
  )
}

1 Answer 1

0

I'm not sure you can wrap you own React component with the react-pdf library. You have to use to given components like or . Depending on your {{ children }} content you have 2 solutions :

  • Change the way you send props to your DocumentForPrint function and work with existing components like View, Text, Image etc.
  • There is a react-pdf-html package which add an component for this PDF generation. This will allow you to use html/css. You should be able to wrap any content using this one
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.