Open tayv opened 1 year 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>
The problem:
Example:
Other Notes: