itextsharp: как разместить изображение полностью внизу? - PullRequest
1 голос
/ 18 декабря 2009

У меня есть изображение, которое я просто хочу разместить внизу страницы. как мне это сделать?

Ответы [ 2 ]

1 голос
/ 19 декабря 2009
    '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()
0 голосов
/ 18 декабря 2009

поместите его вверх ногами и переверните страницу.

редактирование: извини, я наполовину пошутила. здесь есть пример позиционирования изображения с использованием метода Image.setAbsolutePosition. Вы должны быть в состоянии рассчитать параметры для этой функции на основе размера изображения и размера документа, с которым вы работаете.

...