Converting multipage PDF to CCITT4 TIFF

Example requests & Code samples for GdPicture Toolkits.
Post Reply
petermeach
Posts: 21
Joined: Wed Oct 08, 2008 2:59 pm

Converting multipage PDF to CCITT4 TIFF

Post by petermeach » Wed Jul 01, 2009 5:04 pm

Sorry to ask more probably silly questions but I've tried to sort this out for some considerable time and am getting nowhere.
Shown below is the original code. I am splitting pdfs and image files into pages of Tifs and users then select the ones they want. These are then combined into a single file. The files are currently all lzw and the file sizes are huge.
I've tried adding AxImaging1.ConvertTo1Bpp() after the SetNativeImage line and adding a ,4 to the TiffSaveAsNativeMultiPage call but it still ends up as lzw.

I would also like to know if there is a quicker way to do this, this seems to be slow. We currently have students scanning the contents of a lot of filing cabinets and combining then for a document imaging system and they are finding the process too slow and I am finding it fills up my server too quickly.

I would really appreciate some help on this. I've read through many posts on the same subject, but they are all just a bit different and with so many functions available I can't see how I can apply them to my case.

Code: Select all

        For i As Integer = 0 To ListView1.Items.Count - 1
                    AxGdViewer1.DisplayFromFile("c:\overdrive\page" & ListView1.Items.Item(i).Tag + 1 & ".tif")
                    If jFirstpass Then
                        jFirstpass = False
                        AxImaging1.SetNativeImage(AxImaging1.CreateClonedImage(AxGdViewer1.GetNativeImage))
                        Call AxImaging1.TiffSaveAsNativeMultiPage(cOutputFileName)  
                    Else
                        Call AxImaging1.TiffAddToNativeMultiPage(AxGdViewer1.GetNativeImage)
                    End If
        Next
        AxImaging1.TiffCloseNativeMultiPage()
I have also tried to save the pages as compressed tifs, but that doesn't seem to work well either. Original code below

Code: Select all

                    nImageID = AxImaging1.CreateImageFromFile(cFileName)
                    If nImageID <> 0 Then
                        For nCpt = 1 To jPageCount
                            If cFileExt = "tif" Then
                                AxImaging1.TiffSelectPage(nImageID, nCpt)
                            End If
                            K = AxImaging1.SaveAsTIFF("c:\overdrive\page" & jImageCounter & ".tif") 
                            jImageCounter = jImageCounter + 1
                        Next nCpt
                    End If
                    If nImageID <> 0 Then J = AxImaging1.CloseImage(nImageID)

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

Re: Converting multipage PDF to CCITT4 TIFF

Post by Loïc » Fri Jul 03, 2009 6:00 pm

Hi,

Here is a simple way to convert multipage PDF to multipage TIFF with CCITT4 Compression:

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", CompressionCCITT4)
    Else
       Call oImaging.TiffAddToNativeMultiPage(oImaging.GetNativeImage)
       Call oImaging.CloseNativeImage
    End If
Next nPage
oImaging.TiffCloseNativeMultiPage

SSriram
Posts: 23
Joined: Thu Jan 03, 2008 5:51 pm
Location: Chennai India

Re: Converting multipage PDF to CCITT4 TIFF

Post by SSriram » Mon Mar 29, 2010 12:57 pm

Would it be possible to have an API for directly converting a PDF to a multi-page tiff? As it stands now, the performance slows down drastically when the number of pages increases.
SSriram

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest