以下代码将 PDF 文件流式传输到浏览器,但我想将其保存到磁盘 (c:\myfile.pdf)...
Dim FilePath As String = Server.MapPath("/docs/templates/page_1_cover.pdf")
Dim reader As New PdfReader(FilePath)
Dim output As MemoryStream = New MemoryStream()
Dim stamper As PdfStamper = New PdfStamper(reader, output)
stamper.AcroFields.SetField("APPLICANT NAME", "KnowlegeZone")
reader.Close()
stamper.Close()
Response.AddHeader("Content-Disposition", "attachment; filename=YourPDF_I9.pdf")
Response.ContentType = "application/pdf"
Response.BinaryWrite(output.ToArray())
Response.End()
我正在使用 iTextSharp。