Create PDF Documents with PowerShell

Niklas Goude rules.  He posted nice article on how to create PDF documents with PowerShell…

The code snippet from the site is below (slightly modified)

[System.Reflection.Assembly]::LoadFrom(“C:\util\textsharp\itextsharp.dll”)

Function MakePDF($path, $data)
{
$Doc = New-Object iTextSharp.text.Document
[void][iTextSharp.text.pdf.PdfWriter]::GetInstance($Doc, [System.IO.File]::Create($path)  )
$Doc.Open()
$Chunk = New-Object iTextSharp.text.Chunk
[void]$Chunk.Append($data)
$Doc.Add($Chunk)
$Doc.AddAuthor(“User”)
$Doc.Close()
}

 

Leave a Reply

Your email address will not be published. Required fields are marked *