0

Possible Duplicate:
How do I grab a thumbnail screenshot of many websites?

I wrote a script using perl mechanize to login and fetch a page. How can I "print" that page to "pdf" directly from my perl script? I'd like to save a snapshot of how it looks in the browser.

I can get the html using $mech->content();

Community
  • 1
  • 1
user391986
  • 29,536
  • 39
  • 126
  • 205
  • See my answer in [Suggestions for Creating an Image for Each Word in a Text](http://stackoverflow.com/a/7820994/46395). PDF output is supported, and it will be a *real* PDF with selectable text and stuff, not just a huge embedded bitmapped screenshot. There isn't a Mechanize-compatible frontend for this module yet, but it can't be too difficult to write one, because [the previous version has one](http://p3rl.org/Gtk2::WebKit::Mechanize). – daxim Jan 27 '12 at 10:50

3 Answers3

2

Check out wkhtmltopdf - there are variants for PDF and images (PNG etc). It's basically a command-line tool wrapping the webkit html engine. Works quite nicely, and it's cross-platform too. Whether you can get it past your login form will depend on how the target site works.

Richard Huxton
  • 21,516
  • 3
  • 39
  • 51
2

There's a number of CPAN modules to convert HTML to PDF. Feed any of them the content from Mechanize.

Schwern
  • 153,029
  • 25
  • 195
  • 336
-2

The $mech contain plain html so you can't just print it. Check this thread: How do I grab a thumbnail screenshot of many websites?

Community
  • 1
  • 1
gangabass
  • 10,607
  • 2
  • 23
  • 35