Hacker News new | past | comments | ask | show | jobs | submit login

There was some Google properties that had some in-page tool to screenshot the page - wonder how they did that one?



It's all client-side apparently, essentially by writing a page renderer in JavaScript. See:

https://stackoverflow.com/questions/4912092/using-html5-canv...

https://github.com/niklasvh/html2canvas


Note that html2canvas has a lot of limitations, since everything that needs to be rendered has to be implemented from scratch using canvas primitives. If you have (IIRC) shadows, more advanced CSS features, certain SVG icons, etc., your output will be pretty broken. I usually have to do DOM cloning and modify/hide the problematic parts before using html2canvas to generate an image.

It’s incredibly annoying that screenshotting isn’t a DOM API, while the functionality is clearly there in DevTools.

Edit: To add to the annoyance, iOS Safari is extremely stingy with canvas memory.


> It’s incredibly annoying that screenshotting isn’t a DOM API

As if we needed more browser fingerprinting vectors.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: