PDF不会下载itextsharp

时间:2016-09-28 23:41:10

标签: asp.net pdf download itext memorystream

这是我的代码,没有任何错误,但页面没有做任何事情。我不知道错误在哪里,请帮助: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

0 个答案:

没有答案