...o meglio lo fa ma poi il pdf risulta corrotto o comunque non risulta leggibile.... here's the code
codice:
  Protected Function generapdf() As String
        Dim pathpdf As String = ""
        Dim dblDataOra As String = Replace(Now.ToOADate.ToString, ",", "")

        Dim nomefile As String = IDtestata.Value & "_" & dblDataOra

        Dim titleFont = iTextSharp.text.FontFactory.GetFont("Arial", 20, iTextSharp.text.Font.BOLD)
        Dim subTitleFont = iTextSharp.text.FontFactory.GetFont("Arial", 14, iTextSharp.text.Font.BOLD)
        Dim boldTableFont = iTextSharp.text.FontFactory.GetFont("Arial", 12, iTextSharp.text.Font.BOLD)
        Dim endingMessageFont = iTextSharp.text.FontFactory.GetFont("Arial", 10, iTextSharp.text.Font.ITALIC)
        Dim bodyFont = iTextSharp.text.FontFactory.GetFont("Arial", 12, iTextSharp.text.Font.NORMAL)
        Dim smallfont = iTextSharp.text.FontFactory.GetFont("Arial", 7, iTextSharp.text.Font.ITALIC)

        ' Creiamo il documento PDF istanziando l'oggetto Document messo a disposzione
        ' dalla libreria iTextSharp
        Dim Document = New iTextSharp.text.Document(iTextSharp.text.PageSize.A4, 100, 100, 25, 25)
        'Creiamo un oggetto MemoryStream che conterrà in memoria il file pd che andremo
        'via via creando con i passi successivi
        Dim output = New MemoryStream()
        Dim writer = iTextSharp.text.pdf.PdfWriter.GetInstance(Document, output)
        ' Apriamo il documento
        Document.Open()

        Document.Add(New iTextSharp.text.Paragraph("cippalippa", subTitleFont))


        ' Creiamo un ogetto immagine iTextSharp
        Dim logopath As String = ConfigurationManager.AppSettings("rootpath") & "img\mac_warning.png"
        Dim logo = iTextSharp.text.Image.GetInstance(logopath)
        ' Definiamo le propietà dell'immagine
        logo.ScaleToFit(150.0F, 150.0F)
        logo.Alignment = iTextSharp.text.Image.ALIGN_LEFT
        logo.IndentationLeft = 9.0F
        logo.SpacingAfter = 9.0F
        logo.Border = iTextSharp.text.Rectangle.BOX
        'logo.BorderColor = Color.BLACK
        logo.BorderWidth = 5.0F
        Document.Add(logo)

        Dim infoTable = New iTextSharp.text.pdf.PdfPTable(3)
        infoTable.HorizontalAlignment = 0
        infoTable.SpacingBefore = 10
        infoTable.SpacingAfter = 10
        infoTable.DefaultCell.Border = 0
        Dim larghezze() As Integer
        larghezze = {3, 3, 3}
        infoTable.SetWidths(larghezze)

        'cella1
        infoTable.AddCell(logo)
        'cella2
        infoTable.AddCell(New iTextSharp.text.Phrase("contenuto cella2", smallfont))
        'cella3
        infoTable.AddCell(New iTextSharp.text.Phrase("contenuto cella3", smallfont))
        Document.Add(infoTable)


        'creo fisicamente il file dal memorystream
        Dim OutStream As FileStream
        Try
            pathpdf = ConfigurationManager.AppSettings("docpath") & nomefile & ".pdf"
            OutStream = New FileStream(pathpdf, FileMode.OpenOrCreate, FileAccess.Write)
            StreamToStream(output, OutStream)
            pathpdf = "/public/documents/" & nomefile & ".pdf"

        Catch ex As Exception
            'TODO: aggiungere la gestione degli errori
            pathpdf = ""
        Finally
            If Not (OutStream Is Nothing) Then
                OutStream.Close()
            End If
        End Try

        Document.Close()
      
        Return pathpdf
    End Function

    'converte memorystream in stream 
    Public Sub StreamToStream(ByVal InStream As Stream, ByVal OutStream As Stream, Optional ByVal BufSize As Integer = 4096)
        Dim readBytes As Integer
        If BufSize < 1 Then
            Throw New ArgumentOutOfRangeException("BufSize", BufSize, "The buffer size must be greater than zero.")
        End If
        Dim buffer(BufSize - 1) As Byte
        While True
            readBytes = InStream.Read(buffer, 0, BufSize)
            If readBytes = 0 Then Exit While
            OutStream.Write(buffer, 0, readBytes)
        End While
    End Sub
What's wrong?