I am trying to create a script that will convert text documents in a defined directory to PDF files. I am able to make the conversion but the formatting just does not translate. The entire text document gets printed to one line in the PDF. This is being caused by the chunk command. iTextSharp also has phrase and paragraph commands for formatting but I cannot get them to work. This is what I have so far.
[System.Reflection.Assembly]::LoadFrom("C:\itextsharp\itextsharp.dll") Get-ChildItem "C:\PDF\"*.txt -R | ForEach-Object { $object= Get-Content $_.FullName$Doc= New-Object iTextSharp.text.Document[void][iTextSharp.text.pdf.PdfWriter]::GetInstance($Doc, [System.IO.File]::Create("C:\PDF\"+$_.BaseName +".pdf") )$Doc.Open() $Chunk= New-Object iTextSharp.text.Chunk[void]$Chunk.Append($object)$Doc.Add($Chunk)$Doc.AddAuthor("PowerShell")$Doc.Close() }