This code work perfect. The problem was the button was inside a control update panel and that cause some problem. But i already fixed and now works.
Dim documentoPDF As New Document(PageSize.A4, 10, 10, 10, 10)
Dim memStream As MemoryStream = New MemoryStream()
Dim writer As PdfWriter = PdfWriter.GetInstance(documentoPDF, memStream)
documentoPDF.Open()
Dim Paragraph1 As Paragraph = New Paragraph("First paragraph")
documentoPDF.Add(New Paragraph(Paragraph1))
documentoPDF.Close()
Dim bytesInStream As Byte() = memStream.ToArray()
memStream.Close()
'Dim memorystreaam As MemoryStream = New MemoryStream(bytesInStream)
Response.Clear()
Response.ContentType = "application/pdf"
Response.AddHeader("content-disposition", "attachment;filename=FileName.pdf")
Response.Buffer = True
Response.Cache.SetCacheability(HttpCacheability.NoCache)
'Response.OutputStream.Write(memStream.GetBuffer(), 0, memStream.GetBuffer().Length)
Response.BinaryWrite(bytesInStream)
Response.End()
It looks like you are not saving the PDF document into the stream somewhere.