Home | Translator | About us | Overview | Software - Download | Evaluate | Order | Support | Contact | F.A.Q. | Documentations | Blog | Newsletter | Site Content Search
Loading...

Merging 2 PDF using the GdPicture PDF rasterizer

Example requests & Code samples for GdPicture.NET.

Merging 2 PDF using the GdPicture PDF rasterizer

Postby Loïc » Tue Aug 25, 2009 6:08 pm

Here a sample to merge two PDF using rasterization.
Code: Select all
    Public Function Merge2PDF(ByVal PDF1 As String, ByVal PDF2 As String, ByVal OutputPDF As String) As Boolean
        Dim bOK As Boolean = True
        Dim oGdPictureImaging As New GdPicture.GdPictureImaging
        Dim oGdViewer As New GdPicture.GdViewer
        Dim RasterizedPage As Integer
        Dim PdfID As Integer
        Dim TotalPages As Integer = 0

        oGdPictureImaging.SetLicenseNumber("XXX") 'Unlocking GdPicture.NET -> Replace XXX by a commercial or demo license KEY
        PdfID = oGdPictureImaging.PdfNewPdf(OutputPDF, True) 'PDF/A


        If oGdViewer.DisplayFromFile(PDF1) = GdPictureStatus.OK Then
            'Adding all rasterized pages of first to output PDF
            For i As Integer = 1 To oGdViewer.PageCount
                RasterizedPage = oGdViewer.PdfRenderPageToGdPictureImage(200, i)
                oGdPictureImaging.ConvertTo1Bpp(RasterizedPage) 'Comment to keep true color image !!
                oGdPictureImaging.PdfAddImageFromGdPictureImage(PdfID, RasterizedPage)
                oGdPictureImaging.ReleaseGdPictureImage(RasterizedPage)
                TotalPages = TotalPages + 1
            Next
            oGdViewer.CloseDocument()

            If oGdViewer.DisplayFromFile(PDF2) = GdPictureStatus.OK Then
                'Adding all rasterized pages of second to output PDF
                For i As Integer = 1 To oGdViewer.PageCount
                    RasterizedPage = oGdViewer.PdfRenderPageToGdPictureImage(200, i)
                    oGdPictureImaging.ConvertTo1Bpp(RasterizedPage) 'Comment to keep true color image !!
                    oGdPictureImaging.PdfAddImageFromGdPictureImage(PdfID, RasterizedPage)
                    oGdPictureImaging.ReleaseGdPictureImage(RasterizedPage)
                    TotalPages = TotalPages + 1
                Next
                oGdViewer.CloseDocument()

                'Now we have to draw all images of the PDF on its pages
                Dim CurrentPageWidth, CurrentPageHeight As Single
                For i As Integer = 1 To TotalPages
                    CurrentPageWidth = oGdPictureImaging.PdfGetImageWidth(PdfID, i)
                    CurrentPageHeight = oGdPictureImaging.PdfGetImageHeight(PdfID, i)
                    oGdPictureImaging.PdfNewPage(PdfID, CurrentPageWidth, CurrentPageHeight)
                    oGdPictureImaging.PdfDrawImage(PdfID, i, 0, 0, CurrentPageWidth, CurrentPageHeight)
                Next
            Else
                bOK = False
            End If
        Else
            bOK = False
        End If

        oGdPictureImaging.PdfEndPdf(PdfID)

        Return bOK
    End Function



Note: This code creates black & white PDF. To keep page in color just comment these lines:
Code: Select all
oGdPictureImaging.ConvertTo1Bpp(RasterizedPage) 'Comment to keep true color image !!
'...
oGdPictureImaging.ConvertTo1Bpp(RasterizedPage) 'Comment to keep true color image !!
User avatar
Loïc
Site Admin
 
Posts: 3425
Joined: Tue Oct 17, 2006 11:48 pm
Location: France

Re: Merging 2 PDF using the GdPicture PDF rasterizer

Postby kviral » Tue Oct 27, 2009 12:16 pm

Hi Loic,

How can i achieve it through GD Picture ActiveX Pro ?

-Thanks,
Viral
Thank you,

Viral Kothari
Software Eng.
Image
User avatar
kviral
 
Posts: 57
Joined: Thu Oct 01, 2009 4:53 pm
Location: Tarrytown, NY

Re: Merging 2 PDF using the GdPicture PDF rasterizer

Postby Loïc » Tue Oct 27, 2009 12:43 pm

Just have a look on the good section: gdpicture-activex-code-samples/how-merge-pdf-files-t338.html

Kind regards,

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

Re: Merging 2 PDF using the GdPicture PDF rasterizer

Postby kviral » Tue Oct 27, 2009 4:27 pm

Thanks Loic.
Thank you,

Viral Kothari
Software Eng.
Image
User avatar
kviral
 
Posts: 57
Joined: Thu Oct 01, 2009 4:53 pm
Location: Tarrytown, NY


Return to Example requests & Code samples

Who is online

Users browsing this forum: No registered users and 1 guest

cron