If you want the resulting PDF to capture the look & layout of the web page, then I think you're talking about driving the browser, i.e. with Selenium. It's easy to drive the browser to go to certain sites, look for elements on the page, and so on; but I'm not sure how easy it is (or if it's even possible) to access browser features such as Print. Assuming it's possible, then probably what you'd want to do is configure the PDF virtual printer to be the default on your system, with the 50% scaling, default save location, and all that. Even then, there may be some GUI elements you have to access manually, so I'm not sure that this is fully automatable.
An alternative approach might be to use a web service out there somewhere which converts web pages to PDFs. For example, there's PDFcrowd. However, with this one, it looks like the options you get for free don't meet your needs (scaling, for example). You could search around for others.
Updated to fix some tpyos.
I reckon we are the only monastery ever to have a dungeon stuffed with 16,000 zombies .
| [reply] |
he options you get for free don't meed your needs (scaling, for example).
As a thought, every pdf viewer I've used, auto-scales for display.
It might be better for the OP to capture full-sized and let the viewer choose what scaling is best, rather than doing the scaling up front.
With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
| [reply] |
I haven't actually tried, but I think it may be possible because you can send key sequences using WWW::Selenium. If you've configured your defaults properly, it might be as simple as sending ctrl+p followed by an enter. Your script may have to go in and move/rename the resulting file afterwards.
| [reply] |
Would something along the lines of $sel->capture_entire_page_screenshot($filename, $kwargs) from WWW::Selenium be of use?
| [reply] [d/l] |
my $view = Gtk2::WebKit::WebView->new;
$view->signal_connect( 'notify::progress' => \¬ify_progress, undef
+);
$view->signal_connect( 'load_finished' => \&load_finished, undef );
Gtk2 can make PDF screenshots.
By the way, Gtk2::Webkit's capabilities have been greatly enhanced by the recent addition of Glib::Introspection. You might want to ask on the Perl/Gtk2 maillist on how to use Introspection, or whether it could help in your case.
| [reply] [d/l] |
Maybe PhantomJS can do that. If it can, it is probably easier than any approach that uses Perl.
| [reply] |
Doable? With the right module, Perl can DO ANYTHINGNote1 ... even wash your windows!
Note1 Sometimes, though, you have to write the module or even tweak the infrastructure. | [reply] |
| [reply] |