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

Discussions about PDF management.
Post Reply
User avatar
Loïc
Site Admin
Posts: 5575
Joined: Tue Oct 17, 2006 10:48 pm
Location: France
Contact:

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

Post by 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

i90270
Posts: 2
Joined: Mon Mar 28, 2016 5:46 am

Re: Insert a new page in an existing PDF and draw image on i

Post by i90270 » Mon Mar 28, 2016 5:48 am

how to add a empty pdf page at last page?

I've tried , seems impossible

use SwapPages method is not make sense

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

Re: Insert a new page in an existing PDF and draw image on i

Post by Loïc » Mon Mar 28, 2016 12:32 pm

Just use the NewPage() method.

Toliff
Posts: 1
Joined: Thu Jul 13, 2017 2:06 pm

Re: Insert a new page in an existing PDF and draw image on i

Post by Toliff » Thu Jul 20, 2017 8:56 am

Loïc wrote:
Mon Mar 28, 2016 12:32 pm
Just use the NewPage() method.
How do you do that method?

Gabriela
Posts: 37
Joined: Wed Nov 22, 2017 9:52 am

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

Post by Gabriela » Wed Nov 22, 2017 12:20 pm

This topic has been moved. Here you can find updated code snippet based on GdPicture.NET 14:

Adding an image to a newly created PDF document
http://guides.gdpicture.com/content/web ... ment.html
Kind regards,

Gabriela
GdPicture Team

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest