Merging PDFs

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

Merging PDFs

Post by Loïc » Wed Sep 07, 2011 3:38 pm

Code: Select all

      
      Dim GdPicturePDFSrc As New GdPicture.GdPicturePDF
      Dim GdPicturePDFDst As New GdPicture.GdPicturePDF

      GdPicturePDFDst.NewPDF()

      'Append pages of the first PDF
      If GdPicturePDFSrc.LoadFromFile("c:\pdf1.pdf", False) = GdPictureStatus.OK Then
         For i As Integer = 1 To GdPicturePDFSrc.GetPageCount
            GdPicturePDFDst.ClonePage(GdPicturePDFSrc, i)
         Next
      End If
      GdPicturePDFSrc.CloseDocument()

      'Append pages of the second PDF
      If GdPicturePDFSrc.LoadFromFile("c:\pdf2.pdf", False) = GdPictureStatus.OK Then
         For i As Integer = 1 To GdPicturePDFSrc.GetPageCount
            GdPicturePDFDst.ClonePage(GdPicturePDFSrc, i)
         Next
      End If
      GdPicturePDFSrc.CloseDocument()

      'Write the generated PDF
      GdPicturePDFDst.SaveToFile("c:\mypdf.pdf")
      GdPicturePDFDst.CloseDocument()

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

Re: Merging PDFs

Post by Loïc » Mon Oct 17, 2011 7:47 pm

The same approach to merge PDF/A into PDF/A

Code: Select all

          Dim GdPicturePDFSrc As New GdPicture.GdPicturePDF
          Dim GdPicturePDFDst As New GdPicture.GdPicturePDF

          GdPicturePDFDst.NewPDF(True)

          'Append pages of the first PDF
          If GdPicturePDFSrc.LoadFromFile("c:\pdf1.pdf", False) = GdPictureStatus.OK Then
             For i As Integer = 1 To GdPicturePDFSrc.GetPageCount
                GdPicturePDFDst.ClonePage(GdPicturePDFSrc, i)
             Next
          End If
          GdPicturePDFSrc.CloseDocument()

          'Append pages of the second PDF
          If GdPicturePDFSrc.LoadFromFile("c:\pdf2.pdf", False) = GdPictureStatus.OK Then
             For i As Integer = 1 To GdPicturePDFSrc.GetPageCount
                GdPicturePDFDst.ClonePage(GdPicturePDFSrc, i)
             Next
          End If
          GdPicturePDFSrc.CloseDocument()

          'Write the generated PDF
          GdPicturePDFDst.SaveToFile("c:\mypdf.pdf")
          GdPicturePDFDst.CloseDocument()

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

Re: Merging PDFs

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

Here you can find updated code snippet based on GdPicture.NET 14:

Merging two PDF documents by alternating pages from both files
http://guides.gdpicture.com/content/web ... iles.html
Kind regards,

Gabriela
GdPicture Team

Post Reply

Who is online

Users browsing this forum: No registered users and 3 guests