I'm trying to create a pdf with iTextSharp but after I insert some text on the pdf, the pdf gets corrupted and displays this nasty popup on a Pdf Reader (see link)
I've also used another program to check out what was the error problem and it seems the iText library stops adding begin/end blocks when new text is insert
I'm using the latest version of iTextSharp (v.5.5.8.0) And this is the simple code I use
Sub Main()
Dim objPageSize As iTextSharp.text.Rectangle
Dim objDocument As Document
Dim objWriter As pdf.PdfWriter
objPageSize = New Rectangle(842, 595)
objDocument = New Document(objPageSize, 50, 50, 50, 50)
objWriter = PdfWriter.GetInstance(objDocument, New System.IO.FileStream("test.pdf", System.IO.FileMode.Create, System.IO.FileAccess.Write))
Call objDocument.Open()
objWriter.Open()
objWriter.DirectContent.BeginText()
For i As Integer = 0 To 85
Dim ct As ColumnText = New ColumnText(objWriter.DirectContent)
ct.SetSimpleColumn(1, i * 5, 100, 100, 0, Element.ALIGN_LEFT)
Dim phrase As Phrase = New Phrase("hello", FontFactory.GetFont(BaseFont.TIMES_ROMAN, BaseFont.CP1250, False, 4))
ct.SetText(phrase)
ct.Go()
Next
objWriter.DirectContent.EndText()
objDocument.Close()
objWriter.Close()
End Sub
It look like a bug on the library.
Any help would be appreciated
Thank you!