Copy Pages Sample

Example requests & Code samples for GdPicture Toolkits.
Post Reply
bbanet
Posts: 17
Joined: Mon Jun 15, 2009 11:03 pm

Copy Pages Sample

Post by bbanet » Tue Jun 16, 2009 4:12 am

I am trying to copy a range of pages from one multi-page tiff into a new multi-page tiff. Is this possible? I am able to get a single page saved, but can seems to create a file with multiple pages. Is there sample code for this anywhere?

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

Re: Copy Pages Sample

Post by Loïc » Tue Jun 16, 2009 10:33 am

Hi,

Here a function to extract a page range from a multipage tiff to another multipage tiff image:

Code: Select all

    Private Function ExtractPageRange(ByVal ImageSrcPath As String, ByVal ImageDstPath As String, ByVal StartPage As Integer, ByVal EndPage As Integer) As GdPictureStatus
        Dim Status As GdPictureStatus
        Dim oGdPictureImaging As New GdPictureImaging
        Dim ImageSrcID As Integer
        Dim ImageDstID As Integer = 0

        oGdPictureImaging.SetLicenseNumber("XXX") 'Replace XXX by your license KEY

        oGdPictureImaging.TiffOpenMultiPageForWrite(False)
        ImageSrcID = oGdPictureImaging.CreateGdPictureImageFromFile(ImageSrcPath)
        Status = oGdPictureImaging.GetStat
        If Status = GdPictureStatus.OK Then
            For I As Integer = StartPage To EndPage
                Status = oGdPictureImaging.TiffSelectPage(ImageSrcID, I)
                If ImageDstID = 0 Then
                    ImageDstID = oGdPictureImaging.TiffCreateMultiPageFromGdPictureImage(ImageSrcID)
                Else
                    oGdPictureImaging.TiffAppendPageFromGdPictureImage(ImageDstID, ImageSrcID)
                End If
            Next
            Status = oGdPictureImaging.TiffSaveMultiPageToFile(ImageDstID, ImageDstPath, TiffCompression.TiffCompressionCCITT4)
            oGdPictureImaging.ReleaseGdPictureImage(ImageDstID)
            oGdPictureImaging.ReleaseGdPictureImage(ImageSrcID)
        End If

        Return Status
    End Function
Kind regards,

Loïc

Post Reply

Who is online

Users browsing this forum: No registered users and 2 guests