问题
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();
回答1:
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.
回答2:
There's a number of CPAN modules to convert HTML to PDF. Feed any of them the content from Mechanize.
回答3:
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?
来源:https://stackoverflow.com/questions/9029365/mechanize-print-to-pdf