Home HowTo Export Data Sending Results to PDF Files
 

Sending Results to PDF Files

Outputting PowerShell results to text files is convenient yet not perfect. Users can easily change text files, and results may be incomplete, truncated by the PowerShell ETS system.

A much more professional approach would be sending results to PDF files. Now there is free PDF support in PowerShell! With our free module you can use Out-PTSPDF to send any result to a PDF file and enjoy creating sophisticated PDF reports for free in no time.

The module comes with all that is needed. You do not need any additional software and can start producing your own PDF reports even on servers with limited software.

Out-PTSPDF PDF file generator
222.5 KiB
1959 Downloads
Details...

Downloading and Installing

Just download and unpack the module. If you need assistance, take a look at http://www.powertheshell.com/installpsmodule/. Like any other script based PowerShell module, it is a simple copy&paste deployment. No special privileges needed.

Once in place, you simply need to import the module:

Import-Module PDFTools

This adds a new command called Out-PTSPDF. It has plenty of parameters to help you generate the PDF in just the way you want it.

Generate PDF Reports
Out-PTSPDF can turn any PowerShell result in a PDF file

Out-PTSPDF supports autosize, for example: it makes the PDF wide enough to display all content without truncating anything. You can choose different fonts and sizes, include page headers and more.

Example Reports to Play With

Here are some example calls that illustrate how you can use the parameters:

Get-Process | 
  Out-PTSPDF -Path $env:temp\report.pdf -Open -AutoSize -FontName 'Times New Roman' -FontSize 8

Get-Process | 
  Out-PTSPDF -Path $env:temp\report.pdf -Open -AutoSize

Get-Process | 
  Out-PTSPDF -Path $env:temp\report.pdf -Open -Width 120

Get-Service | 
  Out-PTSPDF -Path $env:temp\report.pdf -Open -AutoSize -Property Name, DisplayName, ServiceType -GroupBy Status

Get-Service | 
  Sort-Object Status | 
  Out-PTSPDF -Path $env:temp\report.pdf -Open -AutoSize -Property Name, DisplayName, ServiceType -GroupBy Status

Get-Service | 
  Sort-Object Status | 
  Out-PTSPDF -Path $env:temp\report.pdf -Open -AutoSize -Property Name, DisplayName, ServiceType -GroupBy Status -FontSize 7

Get-Service | 
  Sort-Object Status, Name | 
  Out-PTSPDF -Path $env:temp\report.pdf -Open -AutoSize -Property Name, DisplayName, ServiceType -GroupBy Status -FontSize 7

Get-WmiObject -Class win32_service | 
  Sort-Object StartMode, DisplayName | 
  Out-PTSPDF -Path $env:temp\report.pdf -Open -AutoSize -Property DisplayName, State, ExitCode, PathName -GroupBy StartMode -FontSize 6 -IncludeHeader -HeaderText 'List of Services - Page {0}'

Getting Help

Out-PTSPDF comes with rich help so you can examine its parameters and browse the examples.

You can either call help and view the information separately:

help Out-PTSPDF -Parameters *
help Out-PTSPDF -Examples

Or, if you use PowerShell 3.0, you can view help in a separate viewer:

help Out-PTSPDF -ShowWindow
Complete help builtin

view the help and explore the many examples

Credits

At its heart, Out-PTSPDF uses the free and open-source library PDFSharp which enables it to generate PDF files without any additional software. The binaries are part of the module so you don’t need to install anything else. Note however that if you specify the parameter -Open to open the generated PDF file, you will need a third party PDF viewer of course.

Now we hope you enjoy our latest module. If you live in Europe and look for professional PowerShell training, we might have what you want. Just drop me a line: [email protected]. We do trainings throughout Europe in German and English. We also specialize in PowerShell coaching, project support and any PowerShell related specialty you might be interested in.

 

Out-PTSPDF PDF file generator
Out-PTSPDF PDF file generator
PDFTools.zip
Version: 1.0
222.5 KiB
1959 Downloads
Details...