When I run the following code I get the attached error. If I comment out this line the PDF does load and display correctly so I know that is now the issue. It can also be printed if I click the print button on the navigator. I want to be able to send it print automatically (either via print preview or directly with print). Not sure why this error is occurring.
Imports iTextSharp.text.pdfImports System.IOImports iTextSharp.textPublic Class Form1 Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load Dim document As New Document() Dim pdfStream As New MemoryStream() Dim pdfwriter As PdfWriter = pdfwriter.GetInstance(document, pdfStream) document.Open() Dim over As PdfContentByte = pdfwriter.DirectContent over.BeginText() 'Add logo. 'Dim imagelog As iTextSharp.text.Image = iTextSharp.text.Image.GetInstance(My.Resources.manalivelogo, System.Drawing.Imaging.ImageFormat.Jpeg) 'imagelog.ScalePercent(20) 'imagelog.Transparency = New Integer() {255, 255} 'imagelog.SetAbsolutePosition(25, 800) 'over.AddImage(imagelog) document.Add(New iTextSharp.text.Phrase("More sample text for signature demo")) Dim tr As BaseFont = BaseFont.CreateFont(BaseFont.TIMES_ROMAN, BaseFont.WINANSI, BaseFont.EMBEDDED) Dim btr As BaseFont = BaseFont.CreateFont(BaseFont.TIMES_BOLD, BaseFont.WINANSI, BaseFont.EMBEDDED) over.SetFontAndSize(btr, 12) over.ShowTextAligned(iTextSharp.text.Element.ALIGN_MIDDLE, "2117 Maryland Avenue, Baltimore, MD 21218", 45, 780, 0) over.ShowTextAligned(iTextSharp.text.Element.ALIGN_MIDDLE, "Phone: 410-837-4892 Fax: 410-837-0639", 55, 768, 0) over.EndText() pdfwriter.CloseStream = False document.Close() pdfStream.Position = 0 RadPdfViewer1.LoadDocument(pdfStream) RadPdfViewer1.PrintPreview() End Sub