0

我正在使用下面的代码用文本填充 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()
4

1 回答 1

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()
于 2013-07-22T18:08:18.253 回答