Loading...

Convert from PDF to multipage Tiff or JPEG

Example requests & Code samples for legacy GdPicture products (V 1-2-3-4-5 Series).

Convert from PDF to multipage Tiff or JPEG

Postby coeus » Wed Nov 21, 2007 12:45 am

Is there a way to convert from PDF to tiff? Here is some sample code that works fine for jpg but not PDF

Me.OpenFileDialog1.ShowDialog()
Me.Imaging1.CreateImageFromFile(Me.OpenFileDialog1.FileName)
Me.Imaging1.TiffSaveAsNativeMultiPage(My.Application.Info.DirectoryPath & "\MyConvertFile.tif")
coeus
 
Posts: 5
Joined: Tue Oct 09, 2007 6:42 pm

Code to convert PDF file to multipage tiff image

Postby Loïc » Wed Nov 21, 2007 5:48 pm

Hi,

You can convert PDF to tiff using the GdViewer & Imaging classes:

Code to convert PDF file to multipage tiff image:

Code: Select all
Dim nPage As Long
Dim oImaging As Object, oGdViewer As Object

Set oImaging = CreateObject("gdpicturepro5.Imaging")
Set oGdViewer = CreateObject("gdpicturepro5.GdViewer")

oGdViewer.SetLicenseNumber ("XXXX")
oImaging.SetLicenseNumber ("XXX")
oGdViewer.LockControl = True
oGdViewer.DisplayFromPdfFile ("c:\test.pdf")
For nPage = 1 To oGdViewer.PageCount
    oGdViewer.DisplayFrame (nPage)

    If nPage = 1 Then
       oImaging.SetNativeImage (oImaging.CreateClonedImage(oGdViewer.GetNativeImage))
       Call oImaging.TiffSaveAsNativeMultiPage("c:\output.tif")
    Else
       Call oImaging.TiffAddToNativeMultipage(oGdViewer.GetNativeImage)
    End If
Next nPage
oImaging.TiffCloseNativeMultiPage



Regards,

Loïc
Loïc Carrère, support team.
www.orpalis.com
User avatar
Loïc
Site Admin
 
Posts: 4447
Joined: Tue Oct 17, 2006 10:48 pm
Location: France

Re: Convert from PDF to Tiff

Postby clocklear » Thu Feb 21, 2008 5:27 pm

Can you convert the image format while converting from PDF to Tiff?

For instance my PDF is a 12 page color document and I want a single method to convert it to a black and while multipage Tif. All examples I have seen use single images and not multipage images.
clocklear
 
Posts: 17
Joined: Fri Jan 11, 2008 11:04 pm

Re: Convert from PDF to Tiff

Postby Loïc » Thu Feb 21, 2008 6:16 pm

Hi,

To save as 1bpp multipage tiff using CCITT4 compression file you need to replace this part of the code sample:

Code: Select all
    If nPage = 1 Then
       oImaging.SetNativeImage (oImaging.CreateClonedImage(oGdViewer.GetNativeImage))
       Call oImaging.TiffSaveAsNativeMultiPage("c:\output.tif", CompressionCCITT4)
    Else
       Call oImaging.TiffAddToNativeMultipage(oGdViewer.GetNativeImage)
    End If


By this one:

Code: Select all
   oImaging.SetNativeImage (oImaging.CreateClonedImage(oGdViewer.GetNativeImage))
   oImaging.ConvertTo1Bpp
   If nPage = 1 Then   
      Call oImaging.TiffSaveAsNativeMultiPage("c:\output.tif")
   Else
      Call oImaging.TiffAddToNativeMultipage(oImaging.GetNativeImage)
      oImaging.CloseNativeImage()
   End If


Best regards,

Loïc
Loïc Carrère, support team.
www.orpalis.com
User avatar
Loïc
Site Admin
 
Posts: 4447
Joined: Tue Oct 17, 2006 10:48 pm
Location: France

Re: Convert from PDF to Tiff

Postby marchino » Thu Jan 22, 2009 3:28 pm

I tried your code with a multipage PDF, but only the first page seemed to be converted in black/white.
Thanks
marchino
 
Posts: 3
Joined: Fri Nov 14, 2008 7:55 pm

Re: Convert from PDF to Tiff

Postby Loïc » Fri Jan 23, 2009 11:41 am

Hi,

I tried it. No problem. I have a multipage tiff in b&w for all pages.

I give you the code I used:


Code: Select all
Dim nPage As Long
Dim oImaging As Object, oGdViewer As Object

Set oImaging = CreateObject("gdpicturepro5.Imaging")
Set oGdViewer = CreateObject("gdpicturepro5.GdViewer")

oGdViewer.SetLicenseNumber ("XXX")
oImaging.SetLicenseNumber ("XXX")
oGdViewer.LockControl = True
oGdViewer.DisplayFromPdfFile ("c:\test.pdf")
For nPage = 1 To oGdViewer.PageCount
    oGdViewer.DisplayFrame (nPage)

    oImaging.SetNativeImage (oImaging.CreateClonedImage(oGdViewer.GetNativeImage))
   oImaging.ConvertTo1Bpp
   If nPage = 1 Then
      Call oImaging.TiffSaveAsNativeMultiPage("c:\output.tif")
   Else
      Call oImaging.TiffAddToNativeMultiPage(oImaging.GetNativeImage)
      oImaging.CloseNativeImage
   End If
Next nPage
oImaging.TiffCloseNativeMultiPage



Hope this helps.

Loïc
Loïc Carrère, support team.
www.orpalis.com
User avatar
Loïc
Site Admin
 
Posts: 4447
Joined: Tue Oct 17, 2006 10:48 pm
Location: France

Re: Convert from PDF to Tiff

Postby marchino » Fri Jan 23, 2009 4:01 pm

Shame on me, it was my fault.
Your code does work !!!
Thanks
marchino
 
Posts: 3
Joined: Fri Nov 14, 2008 7:55 pm

Convert from PDF to JPEG

Postby Loïc » Thu Apr 09, 2009 2:41 pm

Another sample to convert multipage PDF to multiple JPEG images:



Code: Select all
 Dim nPage As Long
 Dim oImaging As Object, oGdViewer As Object

 Set oImaging = CreateObject("gdpicturepro5.Imaging")
 Set oGdViewer = CreateObject("gdpicturepro5.GdViewer")

 oGdViewer.SetLicenseNumber ("XXX")

 oGdViewer.LockControl = True
 oGdViewer.DisplayFromPdfFile ("c:\test.pdf")
 For nPage = 1 To oGdViewer.PageCount
     oGdViewer.DisplayFrame (nPage)
     oImaging.SetNativeImage (oGdViewer.GetNativeImage)
     Call oImaging.SaveAsJPEG("c:\output" + Str(nPage) + ".jpg", 75)
 Next nPage

 oGdViewer.CloseImage
Loïc Carrère, support team.
www.orpalis.com
User avatar
Loïc
Site Admin
 
Posts: 4447
Joined: Tue Oct 17, 2006 10:48 pm
Location: France

Re: Convert from PDF to Tiff

Postby kketterman » Mon Apr 27, 2009 3:21 pm

Loïc wrote:Hi,

To save as 1bpp multipage tiff file you need to replace this part of the code sample:

Code: Select all
    If nPage = 1 Then
       oImaging.SetNativeImage (oImaging.CreateClonedImage(oGdViewer.GetNativeImage))
       Call oImaging.TiffSaveAsNativeMultiPage("c:\output.tif")
    Else
       Call oImaging.TiffAddToNativeMultipage(oGdViewer.GetNativeImage)
    End If


By this one:

Code: Select all
   oImaging.SetNativeImage (oImaging.CreateClonedImage(oGdViewer.GetNativeImage))
   oImaging.ConvertTo1Bpp
   If nPage = 1 Then   
      Call oImaging.TiffSaveAsNativeMultiPage("c:\output.tif")
   Else
      Call oImaging.TiffAddToNativeMultipage(oImaging.GetNativeImage)
      oImaging.CloseNativeImage()
   End If


Best regards,

Loïc


I'm still looking but I cannot find the .NET equivalent to these methods.
oImaging.SetNativeImage (oImaging.CreateClonedImage(oGdViewer.GetNativeImage))
User avatar
kketterman
 
Posts: 33
Joined: Tue Apr 21, 2009 6:55 pm

Re: Convert from PDF to multipage Tiff or JPEG

Postby Loïc » Mon Apr 27, 2009 3:41 pm

Loïc Carrère, support team.
www.orpalis.com
User avatar
Loïc
Site Admin
 
Posts: 4447
Joined: Tue Oct 17, 2006 10:48 pm
Location: France


Return to Example requests for Gdpicture V 1-2-3-4-5 Series [Legacy]

Who is online

Users browsing this forum: No registered users and 0 guests

cron