我正在使用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