iTextSharp text file to powershell in Landscape

Viewed 1073

I'm trying to convert a text file to PDF using powershell in landscape.

Currently using a iTextSharp that has got me to great place with text conversion to PDF however I'm not able to find anything to place it in landscape when the lines are added to create the PDF.

Here is what I'm currently using.

[System.Reflection.Assembly]::LoadFrom("I:\powershell\itextsharp.dll")
$doc = New-Object itextsharp.text.document
$stream = [IO.File]::OpenWrite("I:\powershell\test.pdf")
$writer = [itextsharp.text.pdf.PdfWriter]::GetInstance($doc, $stream)
$doc.Open()
[IO.File]::ReadAllLines("I:\powershell\test.txt") | foreach {
    $line = New-Object itextsharp.text.Paragraph($_)
    $doc.Add($line)
}
$doc.Close()
$stream.Close()

I have found some for C# and Java just nothing with powershell.

Tried this which did not work:

$doc = New-Object iTextSharp.text.Document([iTextSharp.text.PageSize]::LEGAL_LANDSCAPE)

Thank you so much. D

1 Answers
Related