Andrew Libby on 22 Nov 2015 09:10:46 -0800

[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]

Re: [PLUG] Need to Convert HTML Page to jpg Image

Hi Casey/ Jon,

You can use xvfb/ selenium to do this.   It might be overkill,
but we've done it.

Short story is we need to pull data from a site regularly, but
they don't porovide an API.  Years back we used mechanize to
login, generate the desired report and download it.  Then they started
doing all this ajaxy stuff that requires javascript in the
user agent.

We would up using selenium running firefox with xvfb.  It's hideous, but
it works.  From time to time when we have problems we use xwd to
capture what's on the screen of a hanging xvfb process.

If having the browser window included your output is acceptable,
this should work.  If not, you'll probably need to do further
work to automatically crop the image.

Lastly, if the HTML renders taller than the browser window, you'll
be missing what's not "on screen" at the time of the screen grab.


On 11/22/15 12:00 PM, Jonathan Simpson wrote:
> I'm interested in this as well
> On Nov 22, 2015 11:58 AM, "Casey Bralla" <
> <>> wrote:
>     I'm writing a web application where users will upload an HTML page
>     which will
>     be shown on another page.   I want to allow the user to see a
>     miniature image
>     of the HTML file they uploaded.
>     Anybody know how to convert an HTML page into a jpg or png file? 
>     I've seen
>     online tools to do this, but I need to have my application automatically
>     convert them on the fly (ie: I need a cli program to convert HTML
>     into a png or
>     jpg.)
>     TIA!
>     --
>     Casey Bralla
>     Chief Nerd in Residence
>     The NerdWorld Organisation
> <>
>     ___________________________________________________________________________
>     Philadelphia Linux Users Group         --       
>     Announcements -
>     General Discussion  -- 
> ___________________________________________________________________________
> Philadelphia Linux Users Group         --
> Announcements -
> General Discussion  --

Andrew Libby
484-887-7505 x 1115
Philadelphia Linux Users Group         --
Announcements -
General Discussion  --