Add image on a new PDF page in the center.

Discussions about PDF management.
Post Reply
coolwater
Posts: 15
Joined: Wed Nov 09, 2011 6:45 pm

Add image on a new PDF page in the center.

Post by coolwater » Tue Dec 20, 2011 1:56 pm

How can I add an image on a new page in the middle of page? I saw an example on how to add an image, but we like to know how to position it in the middle. Thanks!

User avatar
Loïc
Site Admin
Posts: 5881
Joined: Tue Oct 17, 2006 10:48 pm
Location: France
Contact:

Re: Add image on a new PDF page in the center.

Post by Loïc » Tue Dec 20, 2011 5:30 pm

Here we go:

Code: Select all

        Dim oGdPicturePDF As New GdPicturePDF
        Dim oGdPictureImaging As New GdPictureImaging

        oGdPicturePDF.LoadFromFile("c:\input.pdf", False)
        Dim ImageID As Integer = oGdPictureImaging.CreateGdPictureImageFromFile("c:\input.tif")

        oGdPicturePDF.SelectPage(1)

        Dim pageWidth As Single = oGdPicturePDF.GetPageWidth
        Dim pageHeight As Single = oGdPicturePDF.GetPageHeight

        oGdPicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitPoint)
        oGdPicturePDF.SetOrigin(PdfOrigin.PdfOriginBottomLeft)

        Dim imageResName As String = oGdPicturePDF.AddImageFromGdPictureImage(ImageID, False, False)
        oGdPictureImaging.ReleaseGdPictureImage(ImageID)
        oGdPicturePDF.DrawImage(imageResName, pageWidth / 3, pageHeight / 3, pageWidth / 3, pageHeight / 3)
        oGdPicturePDF.SaveToFile("c:\output.pdf")
        oGdPicturePDF.CloseDocument()

coolwater
Posts: 15
Joined: Wed Nov 09, 2011 6:45 pm

Re: Add image on a new PDF page in the center.

Post by coolwater » Thu Dec 22, 2011 12:45 am

Thanks!

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest