1

I am adding support to my website for printing the current page. My website is built with React Js. I am using 'react-to-print', a NPM module, to print the current page. I am following instructions from this page. I am observing an intermittent issue where the text is not printed. Looks like this:

Browser Print Window when using react-to-print

Here is my invocation of the React-to-print UI component:

<ReactToPrint
  documentTitle={title || ''}
  content={onPrint}
  onAfterPrint={onAfterPrint}
  onBeforeGetContent={onBeforePrint}
  removeAfterPrint
  copyStyles
  trigger={() => (
    <div className="pdf-button">
      <div className="pdf-trigger">
        <PictureAsPdfOutlined />
        <div className="text">PDF Download</div>
        </div>
      </div>
    )}
  />

I have tried removing the 'removeAfterPrint' property and many various invocations with no luck. Is there some issue with this library preventing the correct rendering of React UI components?

2
  • Hello. Are you still facing this issue? Commented Jun 11, 2023 at 2:28
  • 1
    @MatthewHerbst no, actually you helped me resolve the issue in the GitHub board. I'll post an answer.
    – P. Avery
    Commented Jun 17, 2023 at 14:33

1 Answer 1

1

Solved this issue by removing duplicate @font-face definitions for a custom font used within my application. Not sure "what" exactly was breaking; I did observe, however, that this issue was also occurring when I called window.print() from the console. The issue was not related to the react-to-print library.

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.