Home | About us | Overview | Softwares - Downloads | Evaluate | Order | Support | old forums | Contact | F.A.Q. | Documentations | Search | Sitemap

How to merge 2 PDF files

Example requests & Code samples for GdPicture ActiveX.

How to merge 2 PDF files

Postby paulo moura on Thu Nov 29, 2007 8:36 pm

Hi !

What is the best way to merge 2 PDF files with GDpicture ?

Thank you !
User avatar
paulo moura
 
Posts: 4
Joined: Thu Sep 06, 2007 10:12 pm
Location: Brasil

Postby Loïc on Fri Nov 30, 2007 1:56 pm

Hi,

You can only merge existing pdf creating output images content PDF mixing the gdviewer & the imaging classes of the GdPicture Pro SDK .


I give you a simple visual basic function to merge 2 pdf :



Code: Select all
Sub Merge2PDF(sInPDFPath1 As String, sInPDFPath2 As String, sOutPDFpath As String)
  Dim nCpt As Long
  Dim nPDFID As Long
  Dim nImageCount As Long
  Dim GdViewer1 As Object, Imaging1 As Object

  Set GdViewer1 = CreateObject("gdpicturepro5.gdviewer")
  Set Imaging1 = CreateObject("gdpicturepro5.imaging")

  GdViewer1.SetLicenseNumber ("LICENSE KEY")
  Imaging1.SetLicenseNumber ("LICENSE KEY")

  Imaging1.PdfNewPdf (sOutPDFpath)
  GdViewer1.LockControl = True
  nImageCount = 0

  GdViewer1.DisplayFromPdfFile (sInPDFPath1)
  For nCpt = 1 To GdViewer1.PageCount
      GdViewer1.DisplayFrame (nCpt)
      If Imaging1.PdfAddImageFromGdPictureImage(GdViewer1.GetNativeImage) <> 0 Then
         nImageCount = nImageCount + 1
      End If
  Next nCpt
  GdViewer1.CloseImage

  GdViewer1.DisplayFromPdfFile (sInPDFPath2)
  For nCpt = 1 To GdViewer1.PageCount
      GdViewer1.DisplayFrame (nCpt)
      If Imaging1.PdfAddImageFromGdPictureImage(GdViewer1.GetNativeImage) <> 0 Then
         nImageCount = nImageCount + 1
      End If
  Next nCpt
  GdViewer1.CloseImage

  For nCpt = 1 To nImageCount
      Call Imaging1.PdfSetPageDimensions(Imaging1.PdfGetImageWidth(nCpt), Imaging1.PdfGetImageHeight(nCpt))
      Imaging1.PdfNewPage
      Call Imaging1.PdfDrawImage(nCpt, 0, 0, Imaging1.PdfGetImageWidth(nCpt), Imaging1.PdfGetImageHeight(nCpt))
      Imaging1.PdfEndPage
  Next nCpt

  Imaging1.PdfSavePdf

  Set GdViewer1 = Nothing
  Set Imaging1 = Nothing
End Sub



Best regards,

Loïc
User avatar
Loïc
Site Admin
 
Posts: 1350
Joined: Tue Oct 17, 2006 11:48 pm
Location: France


Return to Example requests & Code samples

Who is online

Users browsing this forum: No registered users and 0 guests

cron