HTML to PDF blurry images output

HTML to PDF blurry images output

Some websites use dynamic image loading to speed up page loading. Images are fully loaded only when user scrolls the page. To force image loading, we need to emulate user scrolling using custom script. Add the following request parameter to your code:

$parameters["customScript"] = "new Promise(resolve => {\r\nconst distance = 600; \/\/ should be less than or equal to window.innerHeight\r\nconst delay = 100;\r\nconst timer = setInterval(() => {\r\n document.scrollingElement.scrollBy(0, distance);\r\n  if (document.scrollingElement.scrollTop + window.innerHeight >= document.scrollingElement.scrollHeight) {\r\n    clearInterval(timer);\r\n    resolve();\r\n  }\r\n}, delay);});";
Have more questions? Submit a request

0 Comments

Please sign in to leave a comment.