tayv / Project-Bubblegum

React UI + controlled form components
https://bubblegumui.vercel.app
2 stars 0 forks source link

BUG: Printing PDF results in cropped PDF #73

Open tayv opened 1 year ago

tayv commented 1 year ago

The problem:

Example:

Screenshot 2023-07-26 at 10 13 31 PM

Other Notes:

tayv commented 6 months ago

handlePrint uses the react-to-print libraries useReactToPrint hook. This requires a ref to print the iframe.

This is likely the reason why it's printing incorrectly because the ref is attached to the wrapping div instead of DynamicPDF component.

 <div
    ref={pdfRef}
    className={
      "lg:max-h-[80vh] lg:w-[50vw] w-full max-w-screen-lg print:max-h-none select-none"
    }
  >
    {/* Need to pass formData directly as prop instead of useFormContext() or passing all methods because PDFViewer creates a separate context */}
    <PDFViewer style={pdfStyles.pdfViewer}>
      <DynamicPDF formData={testData} />
    </PDFViewer>
 </div>