Home | About us | Overview | Softwares - Downloads | Evaluate | Order | Support | old forums | Contact | F.A.Q. | Documentations | Search | Sitemap

Converting PDF to TIFF & back again

Support for GdPicture Light Imaging Toolkit and GdPicture Pro Imaging ActiveX/SDK.

Converting PDF to TIFF & back again

Postby varcarme on Tue Sep 16, 2008 6:06 pm

I'm converting my PDF images to TIFF so that I can manipulate them (rotate pages, delete pages etc) more easily.

Here's the code

Code: Select all
oImaging = CreateObject("gdpicturepro5.Imaging")
oGdViewer = CreateObject("gdpicturepro5.GdViewer")

oImaging.SetLicenseNumber("xxxxx")
oGDViewer.SetLicenseNumber("xxxxx")

oGdViewer.LockControl = .t.

oGdViewer.DisplayFromPdfFile("c:\input.pdf")

For nPage = 1 TO oGdViewer.PageCount

    oGdViewer.DisplayFrame(nPage)

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

Next nPage

oImaging.TiffCloseNativeMultiPage


This works fine...I can then do whatever I need to do with the image before saving it back as a PDF as follows:

Code: Select all
oImaging = CreateObject("gdpicturepro5.Imaging")
oGdViewer = CreateObject("gdpicturepro5.GdViewer")

oImaging.SetLicenseNumber("xxxxx")
oGDViewer.SetLicenseNumber("xxxxx")

oTiffImage = oImaging.CreateImageFromFile("c:\output.tif")

nStatus = oImaging.PdfCreateFromMultipageTIFF(oTiffImage,"c:\output.pdf")


The problem is....the original PDF was 23k in size....my resulting PDF (even without any changes) is 250k in size.

Is there a better way of doing this?
varcarme
 
Posts: 24
Joined: Tue Feb 05, 2008 9:56 pm

Re: Converting PDF to TIFF & back again

Postby Tom Moran on Wed Sep 17, 2008 8:21 am

Hi Varcarme:

Remember, once you've converted the file to TIFF or back to PDF your pages are now basically image files. The result is these will almost always be significantly larger than native PDF files.

The only real way to control the size that I found would be the colour depth of the image page. The lower the colour depth the smaller the size. If the files contain just plain text you could convert each page to 1bpp. That will result in significantly reduced size. If there is some color you can try 4bpp 16 colors. The size is still pretty good. Then 8bpp quantized to the minium colors, etc. until you get a colour depth that shows the pages similar to the original.

Hope that helps.

Tom Moran
Tom Moran
 
Posts: 49
Joined: Thu May 24, 2007 10:41 am
Location: Phoenix, Arizona

Re: Converting PDF to TIFF & back again

Postby varcarme on Wed Sep 17, 2008 11:47 am

Thanks Tom

Which method do I use to change the colour depth?

Do I do it on the TIFF file or on the PDF?
varcarme
 
Posts: 24
Joined: Tue Feb 05, 2008 9:56 pm

Re: Converting PDF to TIFF & back again

Postby Tom Moran on Thu Sep 18, 2008 5:16 am

Hi Varcarme:

Actually you are going to reduce the colour depth of the TIFF Native Image. You will need to do this for each page of the image. Let's say you want to reduce each page to 16 colours (4bitperpixel) which is usually a good trade off for documents that are largely text with few colours. In the example you gave where you convert each page of the PDF to TIFF add:
....
If nPage = 1 Then
oImaging.SetNativeImage (oImaging.CreateClonedImage(oGdViewer.GetNativeImage))
oImaging.TiffSaveAsNativeMultiPage("c:\output.tif")
Call oImaging.ConvertTo4BppQ
Else
oImaging.TiffAddToNativeMultipage(oGdViewer.GetNativeImage)
Call oImaging.ConvertTo4BppQ
EndIf
.....

You could also do it elsewhere as an edit option of your program. You can find all possible methods of reduction in the Help file under the topic "Palette Conversions & Color Reductions".

Have fun!

Tom
Tom Moran
 
Posts: 49
Joined: Thu May 24, 2007 10:41 am
Location: Phoenix, Arizona


Return to GdPicture [Pro] ActiveX

Who is online

Users browsing this forum: No registered users and 0 guests