1

Can you link printing a webpage to printing a PDF?

Ideally, the PDF would be downloaded once the user uses the browser's print functionality (so a performance hit doesn't affect users who are not printing the website).

I'm looking for a Javascript/CSS print media query solution.

tHemAcHoNe
  • 29
  • 6

1 Answers1

0

To answer my own question:

You can trigger Javascript to run on a print event, redirecting the user to a PDF (works for IE 5+, Firefox 6+, Chrome 9+, and Safari 5+):

Detecting browser print event

Replace the console.logs in the code snippet from the above link with window.location = "http://whatever.you.want.com"

Using this method, the print dialog will open briefly, close immediately and redirect the user to a PDF where they will have to hit the print button again.

Community
  • 1
  • 1
tHemAcHoNe
  • 29
  • 6