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!


In reply to Re: Formatting win32 printer output by Courage
in thread Formatting win32 printer output by jrta

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.