vue-pdf icon indicating copy to clipboard operation
vue-pdf copied to clipboard

Bug when printing a PDF (convert from html to pdf)

Open Marlight96 opened this issue 3 years ago • 6 comments

Hello, I noticed a bug when printing the PDF. But this only happens when I get the PDF from the backend. (There it is converted from HTML to PDF) He displays the PDF as normal and correctly only when these boxes are printed.

In Chrome: image

In Firefox: Blank sheet

Marlight96 avatar Feb 05 '21 22:02 Marlight96

Have you tried either #130 or #156?

hoon-dialog avatar Feb 11 '21 23:02 hoon-dialog

@FranckFreiburger hello, thanks for vue-pdf, any news? 🤔

bgrand-ch avatar Mar 26 '21 14:03 bgrand-ch

Same issue in Chrome using Iron PDF to generate PDF from html string. Any hack workarounds?

dallasbeek avatar Apr 13 '21 16:04 dallasbeek

hello, any news?

solinad21 avatar Jun 04 '21 07:06 solinad21

I have the same problem with a local pdf file.

hulyak avatar Nov 25 '21 01:11 hulyak

I think this is a problem that arises when rendering into a canvas from a different document (which is printing works here).

Note that pdfjs's own viewer implementation re-uses a single canvas instance from the same document, it then creates img elements from the re-used canvas element. I don't use this vue pdf library, but I was doing something similar implementation-wise and the problem resolved for me once I changed things up:

  • document.createElement("canvas");
  • iframe.contentWindow.document.createElement("img")
  • img src based on the canvas contents

https://github.com/mozilla/pdf.js/blob/23b6fde9fc92b827f054e21978e32ce9c13dab82/web/pdf_print_service.js#L177

This does work for me, but I am also a bit worried that URL.createObjectURL (which as used for the img src on img elements created in the iframe's document) might have problems since there are two windows involved.

robrez avatar Jan 20 '22 03:01 robrez