1

我有一张图片,我只想一直放在页面底部。我该怎么做呢?

4

2 回答 2

1
    'Set these as needed
    Dim DocumentWidth = 1000
    Dim DocumentHeight = 1000
    Dim ImagePath = "c:\test.jpg"

    Dim ImageWidth As Integer
    Dim ImageHeight As Integer
    Using Img = System.Drawing.Image.FromFile(ImagePath)
        ImageWidth = Img.Width
        ImageHeight = Img.Height
    End Using

    'Create the document
    Dim D As New Document()
    'Set the page size
    D.SetPageSize(New iTextSharp.text.Rectangle(0, 0, DocumentWidth, DocumentHeight))
    'Zero the margins
    D.SetMargins(0, 0, 0, 0)
    'Create and open the PDF writer
    Dim W = PdfWriter.GetInstance(D, New System.IO.FileStream("C:\test.pdf", IO.FileMode.Create, IO.FileAccess.Write, IO.FileShare.Read))
    D.Open()

    'Make a new image object
    Dim I As New iTextSharp.text.Jpeg(New Uri("file:///" & ImagePath))
    'Lower left is (0,0), upper right is (1000,1000)
    I.SetAbsolutePosition(DocumentWidth - ImageWidth, 0)
    'Add the image
    D.Add(I)
    D.Close()
于 2009-12-18T21:44:27.720 回答
0

将其倒置在页面顶部,然后翻转页面。

编辑:对不起,我是在开玩笑。这里有一个使用 Image.setAbsolutePosition 方法定位图像的示例。您应该能够根据图像的大小和您正在使用的文档的大小来计算提供给此函数的参数。

于 2009-12-18T06:00:18.660 回答