PDF格式保存到光盘 [英] Save PDF to DISC
本文介绍了PDF格式保存到光盘的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
继code PDF文件流的浏览器,但是我想的它保存到磁盘(C:\\ myfile.pdf)...
Following Code streams PDF file to the Browser, however I want to SAVE it to the disk (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的。
I am using iTextSharp.
推荐答案
在这个解决方案,我可以使用PdfStamper来保存文件,而不是使用任何其它方法。
In this solution, I can use "PdfStamper" to Save the file, instead of using any other method.
Dim FilePath As String = Server.MapPath("/docs/templates/page_1_cover.pdf")
Dim reader As New PdfReader(FilePath)
Dim newfile As FileStream
newfile = New FileStream(Server.MapPath("/docs/output/go.pdf"), FileMode.Create, FileAccess.Write)
Dim stamper As PdfStamper = New PdfStamper(reader, newfile)
stamper.AcroFields.SetField("APPLICANT NAME", "han")
reader.Close()
stamper.Close()
这篇关于PDF格式保存到光盘的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文