Yes, it is possible via Win32::API module, but this will lead you to many problems. I did same things a few years ago from C++ and got certain result, but I'm not proud of it.
I would suggest you an idea, which I tried yesterday and it is still in design stage, but anyway it works. Idea is following.
Suppose you have MS Word installed on your machine.
Prepare some template files that will reflect your page settings, some header, footer formattings.
When you need to print a file, using Win32::OLE you're able to manage MSWord to print your contents as you designed to.
Also, I succeeded now to use Internet Explorer browser window via Win32::OLE but did not fully succeeded,
because it does not have "print" method - sad.
Anyway, a code below should get you an idea what I'm trying to explain.
use strict;
use Win32::OLE;
my $ie = Win32::OLE->new('InternetExplorer.Application');
# here we're manipulating at our will
$ie->{Visible} = -1;
$ie->{Left} = 0;
$ie->{Top} = 0;
for (0..150) {
$ie->{Left}++;
$ie->{Top}++;
$ie->{StatusText} = '*'x$_;
}
$ie->Navigate('D:\Work\PerlScripts\doc\tools-describe.htm');
my $idoc = $ie->{Document};
$idoc->{title} = '=+='x10;
# and even replace contents of a window at our will
$idoc->open("text/html","replace");
$idoc->writeln(<<"EOS");
<html>
<body><p>Hello, there!</body>
</html>
EOS
#UNFORTUNATELY $idoc->print; is impossible, because 'print' method lac
+ks here
$ie->ExecWB(6,0);#This will try to print, but it's a cumbersome
sleep(5);
$ie->Quit;
Courage, the Cowardly Dog.
PS. My scratchpad now at "not-fully answered nodes" stage! |