【发布时间】:2018-05-01 16:01:39
【问题描述】:
很抱歉这个问题,但我是 .net 和 vb.net 的新手。我真的需要你的帮助!我在 asp.net (vb.net) 中生成一个 PDF 文件。它应该在浏览器中自动打开,但它给出了错误 - 无法加载 PDF 文档。我看到它是在驱动器上创建并正确打开的。可能是什么问题?
Protected Sub ExportToPDF(sender As Object, e As EventArgs)
Response.ContentType = "application/pdf"
Dim pdfDoc As New Document(PageSize.A4, 50.0F, 10.0F, 10.0F, 10.0F)
PdfWriter.GetInstance(pdfDoc, New
FileStream(Context.Server.MapPath("~/ejik.pdf"), FileMode.CreateNew))
pdfDoc.Open()
pdfDoc.Add(New Paragraph("What is going on?"))
pdfDoc.Close()
Response.Write(pdfDoc)
Response.End()
End Sub
提前感谢您!
P.S.:抱歉,我忘了说我使用 iTextSharp 创建 PDF
【问题讨论】:
-
您可能想要写入 pdfDoc 的字节。
-
抱歉,不明白你的意思
标签: asp.net .net vb.net pdf itext