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: 5881
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: 5881
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.

Gabriela
Posts: 436
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
https://www.gdpicture.com/guides/gdpicture/web ... ment.html

Douglas
Posts: 1
Joined: Thu Sep 16, 2021 9:35 am

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

Post by Douglas » Thu Sep 16, 2021 9:41 am

i902070 wrote:
Wed May 05, 2432 9:48 am
how to add a empty pdf page at last page?

I've tried , seems impossible

use SwapPages method is not make sense

Hey, just as the title says. Is there any free software that is able to do this, I don't want it to merge PDF files by pasting it back to back.

Hugo
Posts: 227
Joined: Tue Dec 18, 2018 10:09 am

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

Post by Hugo » Fri Sep 17, 2021 3:39 pm

Hi Douglas,

As mentioned above, we have many different ways of doing this and our end user product such as Paperscan can achieve this fairly easily.
https://paperscan.orpalis.com/paperscanpro/
You can achieve this very easily in our SDK GdPicture only needing 1 line of code to add this feature.
https://www.gdpicture.com/download-gdpicture/

Regards,
Hugo Cudd
Technical Support

Post Reply

Who is online

Users browsing this forum: Semrush [Bot] and 1 guest