Changing printer output to \"landscape\"

Welcome Forums General PowerShell Q&A Changing printer output to \"landscape\"

This topic contains 4 replies, has 4 voices, and was last updated by

 
Participant
3 months, 2 weeks ago.

  • Author
    Posts
  • #102889

    Participant
    Points: 0
    Rank: Member
    .Synopsis
        This function prints a letter size Table of Contents for the file cabinet.
    .DESCRIPTION
        This printout includes the full directory path to each end folder, which shows what kind of file information was stored in each end folder; for example, Credit Union 1 statements by year.
        When used in conjunction with the jewel case contents, it is easier to identify file contents. Sometimes the actual file names are rather generic, and you need to see the containing folder
        and directory path.
     .EXAMPLE
        This cmdlet has no screen output.     
    #>
    function Write-TableOfContents
    {
        [CmdletBinding()]
        Param
            ()
        Begin
        {
        }
        Process
        {
                 Get-FilesReadyToArchive | Sort-Object -Property directory | Format-Table -GroupBy directory -Property 'file name', 'file type','file size (KB)','Date Created' -Wrap | Out-Printer
         }
         End
         {
         }
    }
    

    Here is a cmdlet from a module I wrote that gives me a printed copy of the files I am archiving onto storage media. Normally, everything prints fine, but if any 'file name' is really long, the remaining columns get pushed so far to the right that the last column (date created) gets wrapped twice. The printer output is portrait. I believe if this were printed in landscape, the extra width for the first column wouldn't matter, and every object would appear on a single line. However, help for "out-printer" reveals no way to change any of the common printer preferences. I tried setting the preference to "landscape" using the control panel, but the printer ignored that. (However, a test page did print in Landscape) Any suggestions?

  • #102916

    Keymaster
    Points: 1,524
    Helping HandTeam Member
    Rank: Community Hero

    That's entirely controlled by the printer and its driver. There's nothing native in PowerShell to do it; yo could look into WMI/CIM in the event the printer driver obeys the WMI-derived printer settings, but it's a crapshoot.

  • #102931

    Participant
    Points: 30
    Rank: Member

    You can see if there is a printer property or configuration you can manipulate, see below for some examples:

    https://stackoverflow.com/questions/33590109/powershell-change-printer-configuration-from-administration-tab

    It may be easier to put the content in a Word\Excel\PDF document that has print properties rather than trying to manipulate a print job or the printer.

  • #102943

    Participant
    Points: 37
    Helping Hand
    Rank: Member

    Out-Printer isn't meant to do anything fancy. It just sends text to a printer.

    If you need to format your output like this, you'll likely have best luck with a Word COM Object.

  • #104233

    Participant
    Points: 0
    Rank: Member

    Results... 1st, I tried setting "Snagit" as the default printer, which would allow me to go into the Snagit editor and preview the print job. However, no such luck. What showed up was already portrait and wrapped, as before. 2nd, I tried setting printer preferences for my HP 8600 to "landscape" using Windows control panel. This didn't work (at first.) 3rd, I finally just modified the code to eliminate the last column – 'Date Created', which allowed the printout to fit without wrapping. Then, after power cycling the printer due to a WiFi problem, a second attempt at printing did show up in landscape, minus the last column. So... replace the 'Date Created' column in the code and rerun. Now the printout was in landscape, with enough room to prevent wrapping. Apparently, the printer retains the print preferences from the last print job, but if it's rebooted, and the new print job that is generated by my Powershell cmdlet as no "attached" preferences, the printer gets the default preferences from the OS..
    Thanks, everyone!

The topic ‘Changing printer output to \"landscape\"’ is closed to new replies.