Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris

Re: Is Perl capable of doing this?

by jdporter (Canon)
on Apr 06, 2012 at 18:12 UTC ( #963848=note: print w/replies, xml ) Need Help??

in reply to Is Perl capable of doing this?

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.

Replies are listed 'Best First'.
Re^2: Is Perl capable of doing this?
by BrowserUk (Pope) on Apr 06, 2012 at 19:03 UTC
    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".
    In the absence of evidence, opinion is indistinguishable from prejudice.

    The start of some sanity?

Re^2: Is Perl capable of doing this?
by Riales (Hermit) on Apr 06, 2012 at 18:23 UTC

    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.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://963848]
[choroba]: Discipulus Similar question: What happened to neuter in Italian?

How do I use this? | Other CB clients
Other Users?
Others romping around the Monastery: (7)
As of 2017-11-23 12:20 GMT
Find Nodes?
    Voting Booth?
    In order to be able to say "I know Perl", you must have:

    Results (334 votes). Check out past polls.