[VB6] Migrating from ActiveX to COM - convert pdf 2 tiff

Discussions about GdPicture.NET usage in non managed applications built in vb6, Delphi, vfp, MFC c++ etc...
Post Reply
jgeizhals
Posts: 2
Joined: Wed Nov 23, 2011 8:23 am

[VB6] Migrating from ActiveX to COM - convert pdf 2 tiff

Post by jgeizhals » Wed Nov 23, 2011 8:45 am

When the ActiveX version was available (GD Toolkit Pro v 5) I had a very easy program to convert a multipage PDF to a multipage TIFF. How do I do this in the COM version now?

Code: Select all

Private Sub Form_Load()
    Dim strArgs() As String
    Dim inFile As String
    Dim outFile As String
  
    inFile = "C:\S.pdf"
    outFile = "C:\S.tif"
   
    Dim nPage As Long
    Dim Imaging As Object

    Set Imaging = CreateObject("gdpicturepro5.Imaging")
    GdViewer.SetLicenseNumber ("XXX")
    Imaging.SetLicenseNumber ("XXX")
    GdViewer.SetZoomFitControl
    GdViewer.LockControl = True
    GdViewer.DisplayFromPdfFile (inFile)
    
    For nPage = 1 To GdViewer.PageCount
        GdViewer.DisplayFrame (nPage)

        If nPage = 1 Then
            Imaging.SetNativeImage (Imaging.CreateClonedImage(GdViewer.GetNativeImage))
            Call Imaging.TiffSaveAsNativeMultiPage(outFile)
        Else
            Call Imaging.TiffAddToNativeMultiPage(GdViewer.GetNativeImage)
        End If
    Next nPage

    Imaging.TiffCloseNativeMultiPage
    Unload Me
End Sub

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

Re: [VB6] Migrating from ActiveX to COM - convert pdf 2 tiff

Post by Loïc » Wed Nov 23, 2011 8:23 pm

Hi,

You have to use GdPciturePDF & GdPictureImaging objects.

here a sample:

Code: Select all

 Dim FileIn As String
 Dim FileOut As String
 Dim oGdPicturePDF As New GdPicturePDF
 Dim oGdPictureImaging As New GdPictureImaging
 Dim X As Integer
 Dim ImageID As Integer
 Dim TiffID As Integer
 Dim PageCount As Integer
 
 FileIn = "c:\test.pdf"
 FileOut = "c:\test.tif"
 PageCount = 0
 If oGdPicturePDF.LoadFromFile(FileIn, False) = GdPictureStatus_OK Then
   For X = 1 To oGdPicturePDF.GetPageCount()
      oGdPicturePDF.SelectPage (X)
      ImageID = oGdPicturePDF.RenderPageToGdPictureImage(200, True)
      If ImageID <> 0 Then
         PageCount = PageCount + 1
         If PageCount = 1 Then
            TiffID = ImageID
            Call oGdPictureImaging.TiffSaveAsMultiPageFile(TiffID, FileOut, TiffCompression_TiffCompressionAUTO)
         Else
            Call oGdPictureImaging.TiffAddToMultiPageFile(TiffID, ImageID)
         End If
         oGdPictureImaging.ReleaseGdPictureImage (ImageID)
      Else
        MsgBox "Error rendering page " & Str(X)
      End If
   Next X
   oGdPictureImaging.TiffCloseMultiPageFile (TiffID)
   MsgBox "Done!"
 Else
    MsgBox "can't open " + FileIn
 End If

jgeizhals
Posts: 2
Joined: Wed Nov 23, 2011 8:23 am

Re: [VB6] Migrating from ActiveX to COM - convert pdf 2 tiff

Post by jgeizhals » Tue Nov 29, 2011 8:46 am

Thanks for the quick response. Now, were can I find documentation/tutorial so that I don't have to keep bothering you every time I have to get anything done? Thanks again!

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

Re: [VB6] Migrating from ActiveX to COM - convert pdf 2 tiff

Post by Loïc » Tue Nov 29, 2011 3:29 pm

Hi,

The doc can be found here: https://www.gdpicture.com/guides/gdpicture

Kind regards,

Loïc

Post Reply

Who is online

Users browsing this forum: No registered users and 2 guests