0

This is my code, don't have any error but page doesn't does nothing. I don't know where is the error, please help :O

 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()


documentoPDF.Add(paragraph8)



        writer.CloseStream = False

        documentoPDF.Close()

        Try


            Dim bytesInStream As Byte() = memStream.ToArray()
            Dim memorystreaam As MemoryStream = New MemoryStream(bytesInStream)

            Response.Clear()
            Response.ClearContent()
            Response.ClearHeaders()
            Response.ContentType = "application/pdf"
            Response.AddHeader("content-length", bytesInStream.Length.ToString)
            Response.AddHeader("content-disposition", "attachment;filename=Prueba.pdf")
            Response.Buffer = True
            Response.OutputStream.Write(bytesInStream, 0, bytesInStream.Length)


            Response.Flush()
        HttpContext.Current.ApplicationInstance.CompleteRequest()
    Catch ex As Exception
        mesg(ex.Message)

    End Try

aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa

  • Why did you add `writer.CloseStream = False`? Why do you create the `memorystreaam` object (strange spelling by the way) with the `bytesInSteam`? Also: hasn't this question been answered many times already? See http://stackoverflow.com/questions/8505995/itextsharp-generated-pdf-how-to-send-the-pdf-to-the-client-and-add-a-prompt http://stackoverflow.com/questions/24127071/itextsharp-is-producing-a-corrupt-pdf-with-response http://stackoverflow.com/questions/6247583/itextsharp-generating-pdf-into-client-browser-vb-net – Bruno Lowagie Sep 29 '16 at 09:24
  • I closed this question because it's the second time you asked this question and you didn't clarify the original question (on the contrary). You should improve your original question if the answer provided didn't help. You should NOT post an identical question 7 hours after posting the original question. – Bruno Lowagie Sep 29 '16 at 10:04

0 Answers0