Loading...

Insert a new page in an existing PDF and draw image on it

Support for GdPicturePDF Plugin.

Insert a new page in an existing PDF and draw image on it

Postby Loïc » Tue Sep 06, 2011 3:01 pm

Open an existing PDF, insert an A4 page in second page then draw an image on the whole page surface

Code: Select all
         Dim oGdPicturePDF As New GdPicturePDF
         Dim oGdPictureImaging As New GdPictureImaging
   
   
         Dim ImageID As Integer = oGdPictureImaging.CreateGdPictureImageFromFile("c:\test.tif")
   
         If ImageID > 0 AndAlso oGdPicturePDF.LoadFromFile("c:\test.pdf", True) = GdPictureStatus.OK Then
   
            'Add the image as resource in the PDF document
            Dim image_res_name As String = oGdPicturePDF.AddImageFromGdPictureImage(ImageID, False, False)
            oGdPictureImaging.ReleaseGdPictureImage(ImageID)
   
            'Insert a new blank A4 page as second page of the document.
            Dim pageWidth As Single = 8.27
            Dim pageHeight As Single = 11.69
            Dim pagePosition As Integer = 2
            oGdPicturePDF.SetOrigin(PdfOrigin.PdfOriginBottomLeft)
            oGdPicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitInch)
            oGdPicturePDF.InsertPage(pageWidth, pageHeight, pagePosition)
            oGdPicturePDF.SelectPage(pagePosition)
            'Draw the image on the PDF page
            oGdPicturePDF.DrawImage(image_res_name, 0, 0, pageWidth, pageHeight)
            oGdPicturePDF.SaveToFileInc("c:\test.pdf")
            oGdPicturePDF.CloseDocument()
   
         End If
Loïc Carrère, support team.
www.orpalis.com
User avatar
Loïc
Site Admin
 
Posts: 4445
Joined: Tue Oct 17, 2006 10:48 pm
Location: France

Return to GdPicture PDF Plugin

Who is online

Users browsing this forum: No registered users and 0 guests

cron