79483427

Date: 2025-03-04 10:52:44
Score: 0.5
Natty:
Report link

I was unable to recreate this same exact issue for another website; for other websites when you screenshot using driver.execute_cdp_cmd("Page.printToPDF", params) the screenshot stores the entire webpage with no need to scroll - so not sure why it didn't work for Coursera.

So to resolve, I changed the params being passed into this call and the zoom:

driver.execute_script("document.body.style.zoom='90%'")
params = {'landscape': False, 'paperWidth': 12, 'paperHeight': 25}
data = driver.execute_cdp_cmd("Page.printToPDF", params)

This seemed to do the trick.

Code: https://github.com/psymbio/math_ml/blob/main/coursera_pdf_maker.ipynb

PDF: https://github.com/psymbio/math_ml/blob/main/course_1/week_1/practical_quiz_1.pdf

It's sad this doesn't render on GitHub.

Reasons:
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Self-answer (0.5):
  • Low reputation (1):
Posted by: salt lake