Skip to main content

Posts

Showing posts with the label html2canvas

Java servlet to work as a proxy for html2canvas

So I wrote about how I used the html2canvas to solve one of the problems at work in this post . Now have a read of the  documentation  for html2canvas, and focus on the bit about same origin content. So in summary, if the web page you are trying to capture the screenshot of, contains an image that comes from a different domain, that image wont be in the screenshot that you just captured with the library. So the only way to ensure cross origin content is included in the screenshot is via a proxy. Now the author of html2canvas, has provided proxies, for Python  and Node.js , but they are not of use to me as I was using the html2canvas in a Java project. So I had to write my own little Java servlet to get the job done. So it was a very simple servlet and I was just surprised that there wasn't a Java based proxy out there. Anyway so the servlet that I had to write to work as a proxy was something similar to what I have shared in this Github repo . I am sure you realise t...