我使用下面的代码填充带有文本的pdf。是否可以添加一条线?或横跨pdf的横向规则,所以我将文本分成几个部分?
Session("PDF") = Session("Hospital") + Environment.NewLine + Session("HospitalAddress") + Environment.NewLine + Session("HospitalCity")
Dim myUniqueFileName = String.Format("{0}.pdf", random)
Dim pdfWrite As PdfWriter = PdfWriter.GetInstance(Doc1, New FileStream(path & myUniqueFileName, FileMode.Create))
Doc1.Open()
Dim test As String
test = Session("PDF")
Dim imagepath As String = Server.MapPath(".") & "/images/Header.png"
Dim image As iTextSharp.text.Image = iTextSharp.text.Image.GetInstance(imagepath)
image.ScalePercent(70.0F)
Doc1.Add(image)
Doc1.Add(New Paragraph(test))
Doc1.Close()
答案 0 :(得分:0)
你必须像这样绘制水平线:
Dim cb As PdfContentByte = pdfWrite.DirectContent
' Set thickness to 2.0, rather than 1.0 default
cb.SetLineWidth(2F)
' 1.0 = black; 0.0 = white
cb.SetGrayStroke(0.95F)
' Set x and y coordinates for points of line to draw between, numbers made up for this example
cb.MoveTo(25, 50)
cb.LineTo(400, 50)
cb.Stroke()