Page 1 of 1
Convert from PDF to multipage Tiff or JPEG
Posted: Wed Nov 21, 2007 12:45 am
by coeus
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")
Code to convert PDF file to multipage tiff image
Posted: Wed Nov 21, 2007 5:48 pm
by Loïc
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
Re: Convert from PDF to Tiff
Posted: Thu Feb 21, 2008 5:27 pm
by clocklear
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.
Re: Convert from PDF to Tiff
Posted: Thu Feb 21, 2008 6:16 pm
by Loïc
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
Re: Convert from PDF to Tiff
Posted: Thu Jan 22, 2009 3:28 pm
by marchino
I tried your code with a multipage PDF, but only the first page seemed to be converted in black/white.
Thanks
Re: Convert from PDF to Tiff
Posted: Fri Jan 23, 2009 11:41 am
by Loïc
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
Re: Convert from PDF to Tiff
Posted: Fri Jan 23, 2009 4:01 pm
by marchino
Shame on me, it was my fault.
Your code does work !!!
Thanks
Convert from PDF to JPEG
Posted: Thu Apr 09, 2009 2:41 pm
by Loïc
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
Re: Convert from PDF to Tiff
Posted: Mon Apr 27, 2009 3:21 pm
by kketterman
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))
Re: Convert from PDF to multipage Tiff or JPEG
Posted: Mon Apr 27, 2009 3:41 pm
by Loïc
Hi,
I created a sample for GdPicture.NET. See here:
viewtopic.php?t=1482
Re: Convert from PDF to multipage Tiff or JPEG
Posted: Thu May 02, 2013 2:24 pm
by SkinnyPete
Damn thats a nice workaround man
ive been using converter sites like
http://convertjpgpdf.net/ to do my conversions but i dont appreciate them very much^^
so thanks for this
regards
peter
Re: Convert from PDF to multipage Tiff or JPEG
Posted: Thu May 02, 2013 2:29 pm
by SkinnyPete
thanks a lot for this
Re: Convert from PDF to multipage Tiff or JPEG
Posted: Tue Nov 14, 2023 6:14 pm
by tempaboult
Can you convert the image format while converting from PDF to Tiff?
myindigocard
jjsploit download