An easy workaround (although not very general) might leverage what type of networked printer you have. A JetDirect print server generally has FTP through which you can transfer any type of file (plain text, PCL, PostScript, raw) the printer attached to it can print. I'm not sure how to specify landscape printing other than at the printer then, though. A PostScript file can specify the orientation of its contents.

If you're using a networked printer through the UNC path from Windows, you can probably control a PDF or ODF-compatible application on the server via OLE to do the printing. Whether that'd be easier than figuring out the detailed layout methods of Win32::Printer or getting Win32::Printer::Direct to use Win32::Printer's landscape mode I couldn't say.

In the vein of using the DOS "print" command, that works with your server's print driver IIRC, so you should be able to set all of your printers (if you have more than one) to landscape on the server. Unfortunately, portrait v. landscape settings in the driver never seem to have worked with that command. It lets you specify which printer device to print to, including UNC paths. print /d:\\unc\path filename should work. It's easy enough to share a printer with a name "foo" on the server with a name of "bar", then shell out to print /d:\\bar\foo datafile. If it did landscape, you'd really be in luck.

If you can get the file to an lpd somewhere from the Windows box, that might be worth investigating as there's an lpr for Windows (probably several). There are also lpd servers that run on Windows, for that matter.

By using a PostScript-compatible printer, a PostScript document that sets its own orientation, and either the CLI-based print command or an lpr/lpd combo, you might have a solution that way.


In reply to Re^3: Print a text file to a Windows network printer in a landscape orientation. by mr_mischief
in thread Print a text file to a Windows network printer in a landscape orientation. by iskinner

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.