解析问题HTML - > PDF使用iText

时间:2018-01-26 16:00:12

标签: html css vb.net pdf itext

使用iText将html转换为PDF时出现问题。我有代码:

Dim currentContext As String = 
   HttpContext.Current.Server.MapPath("~/ejik.pdf")
Dim pdfDoc As New Document()
pdfDoc = New Document(PageSize.A4, 10.0F, 10.0F, 10.0F, 10.0F)
Dim writer As PdfWriter = PdfWriter.GetInstance(pdfDoc, New 
   FileStream(currentContext, FileMode.CreateNew))
pdfDoc.Open()
Dim sr
sr = New StringReader("<p style='position:absolute; left:100; top:400; 
   color:red'>Hello, world!</p>")
XMLWorkerHelper.GetInstance().ParseXHtml(writer, pdfDoc, sr)
pdfDoc.Close()

我收到了PDF文件,其中“Hello,world”未正确定位。看起来iText无法识别"position:absolute; left:100; top:400;"。你能告诉我任何想法吗?谢谢你的回答!

0 个答案:

没有答案