I would like to render individual HTML elements into PNGs using Phantom.JS. Does anyone know if this is possible? Also, how would I use Phantom.js to render a page that the user is already looking at?
相关问题
- Is there a limit to how many levels you can nest i
- How to toggle on Order in ReactJS
- void before promise syntax
- Keeping track of variable instances
- Can php detect if javascript is on or not?
I had the same need, I tried this and it worked fine for me :
don't forget the
http://www
in the URLYou can use the CasperJS, another project based on PhantomJS.
Working example.
To only render part of a page you need to set the clipRect attribute for the page and then render it.
I don't understand the second part of your question. Phantom.js is headless meaning that there is no actual display that a user is looking at.
The solution below works for me.
But I notice that this on works only if we are rendering an image not a pdf. To wokaround this for pdf, try this
This links may help: How to hide all elements except one using jquery?
https://github.com/ariya/phantomjs/issues/10465