itextsharp:如何将图像一直放在底部?

发布于 2024-08-14 18:09:17 字数 35 浏览 6 评论 0原文

我有一张图像,我只想将其一直放置在页面底部。我该怎么做?

i have an image that i just want to place all the way at the bottom of the page. how do i do this?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

隱形的亼 2024-08-21 18:09:17
    '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()
    '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()
感性不性感 2024-08-21 18:09:17

将其上下颠倒放在页面顶部,然后翻转页面。

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

place it at the top of the page upside down, and flip the page.

edit:
sorry, i was half kidding. there's an example here of positioning an image using the Image.setAbsolutePosition method. You should be able to calculate the parameters to supply to this function based on the size of the image and the size of the document you're working with.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文