gpt4 book ai didi

asp.net - 将 PDF 保存到 DISC

转载 作者:行者123 更新时间:2023-12-02 05:26:55 25 4
gpt4 key购买 nike

以下代码将 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。

最佳答案

这应该和调用 File. WriteAllBytes

Response.AddHeader("Content-Disposition", "attachment; filename=YourPDF_I9.pdf")
Response.ContentType = "application/pdf"

Dim data = output.ToArray();

File.WriteAllBytes("c:\\myfile.pdf",data)

Response.BinaryWrite(data)
Response.End()

关于asp.net - 将 PDF 保存到 DISC,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12948053/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com