【发布时间】:2011-11-28 18:03:57
【问题描述】:
我正在使用 FreeTextBox.dll 获取用户输入,并将该信息以 HTML 格式存储在数据库中。用户输入的示例如下:
133 peachtree st ne
atlanta,ga 30303
404-652-7777Cindy Cooley
www.somecompany.com
产品管理mgr=
我希望 HTMLWorker 保留用户输入的空白,但它会将其去除。有没有办法保留用户的空白?以下是我如何创建 PDF 文档的示例。
Public Shared Sub CreatePreviewPDF(ByVal vsHTML As String, ByVal vsFileName As String)
Dim output As New MemoryStream() Dim oDocument As New Document(PageSize.LETTER) Dim writer As PdfWriter = PdfWriter.GetInstance(oDocument, output) Dim oFont As New Font(Font.FontFamily.TIMES_ROMAN, 8, Font.NORMAL, BaseColor.BLACK) Using output Using writer Using oDocument oDocument.Open() Using sr As New StringReader(vsHTML) Using worker As New html.simpleparser.HTMLWorker(oDocument) worker.StartDocument() worker.SetInsidePRE(True) worker.Parse(sr) worker.EndDocument() worker.Close() oDocument.Close() End Using End Using HttpContext.Current.Response.ContentType = "application/pdf" HttpContext.Current.Response.AddHeader("Content-Disposition", String.Format("attachment;filename={0}.pdf", vsFileName)) HttpContext.Current.Response.BinaryWrite(output.ToArray()) HttpContext.Current.Response.End() End Using End Using output.Close() End Using End Sub
【问题讨论】:
-
只是给你一些帮助 - 这可能是错误的,如果你将它重新标记到 Visual Basic,你可能会得到更多帮助。
标签: html vb.net pdf itextsharp