我正在使用FreeTextBox.dll来获取用户输入,并将该信息以HTML格式存储在数据库中。用户输入的samle是如下:iTextSharp HTML to PDF保留空格
133 Peachtree St NE
Atlanta, GA 30303
404-652-7777Cindy Cooley
www.somecompany.com
Product Stewardship Mgr9/9/2011
Deidre's Company
123 Test St
Atlanta, GA 30303
Test test.
我想HTMLWorker持之以恒的白色空间的用户进入,但它剥离出来。有没有办法维持用户的空白空间?以下是我如何创建我的PDF文档的示例。
公共共享子CreatePreviewPDF(BYVAL vsHTML作为字符串,BYVAL vsFileName作为字符串)
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,可能会获得更多帮助。 – element119