react-to-print: Printing failed because the `contentWindow` of the print iframe did not load

Printing failed because the contentWindow of the print iframe did not load

About this issue

  • Original URL
  • State: open
  • Created 5 years ago
  • Comments: 23 (10 by maintainers)

Most upvoted comments

I have these problems:

  1. In chrome mobile it does not work to print (IOS), basically it does not take correctly the content but it takes the whole page.
  2. In mobile the documentTitle, does not work, it takes the title of the site.
  3. On android it just doesn’t work as it should, it takes another behaviour.
  4. On IOS, it only works on Safari, but the problem is that it takes more content than expected.

@MatthewHerbst suddenly its working again, without any change… I dont know what to tell you lol. probably some version mismatch

@MatthewHerbst Desktop chrome. nothing more. its an nextjs app… this was working before

Is there any update about the issue?

Unfortunately we’re at the mercy of Android here 😢

@JJozef For Chrome mobile you can do:

  const reactToPrintFn = useReactToPrint({
    contentRef: targetRef,
    preserveAfterPrint: true,
  });

For the title, you have to change the title of the page unfortunately

Hello guys any update about this?

@MatthewHerbst I found the bug. removeAfterPrint was causing it. If I remove that prop, it works fine…

@tiffanytut0225 could you please make a working Codesandbox or similar replicating the problem ideally? It’s hard to debug parts of your code

The same code I provided works on Codesandbox. 😂 Maybe other things caused the error, I will try to find out. Thank you for your reply.