Click here to Skip to main content
Licence BSD
First Posted 7 Nov 2002
Views 255,822
Bookmarked 80 times

Convert Tiff To Pdf

By | 17 Feb 2003 | Article
Tiff To PDF conversion Source Code.

Introduction

After looking everywhere for TiffToPdf source code, I decided to write my own conversion routine. It is fairly simple and straight forward and it fits my needs. I decided to return the favor and post this code here so others that need the capability can utilize it as well. Currently it only supports Tiff Image files in Fax formats.

What you need to compile.

You will need CXImage to compile and build. It only uses the CXFile / LIBTIFF functions of CXImage but CXImage is a nice library anyways.

Where to go from here

If you would like to extend it and make improvements on it please send me an e-mail with your improvements, and suggestions. It would be nice to extend this functionality.

How to use

This is the class function declaration for CDTPDFConvert::TiffToPdf The function requires an input tiff file. If there is no output pdf file it will use the tiff file name with the .pdf extension, the additional paramaters are for the pdf info header.

int TiffToPdf( char* a_tiff, char* a_pdf, char* a_szCreator,
                         char* a_szCreationDate, char * a_szAuthor,
                                   char * a_szProducer, char * a_szTitle,
                                   char * a_szSubject, char * a_szKeywords  );

This is an example of how to use the class. The class is wrapped with exception handling and has a error string that returns limited info if there was a problem. The error checking and exception handling can be improved drastically but for this purpose if you choose to use the code that is your responsibility.

void main()
{ 
  CDTPDFConvert convert;
  if (convert.TiffToPdf( a_in_tiff, a_out_pdf, Additional Paramaters ) < 1) {
    printf( convert.m_szErrorCode );
  } else
    printf( "Converted Tiff to Pdf!" );
}

Edit Revision

21 Nov 2002 - Initial Editing

18 Feb 2003 - I removed CXImage Dependicies (Code is loosely based on CXImage Lib a really cool library get it!). I also added libtiff into zip file. Added several image compression routines, and made it easier to build.

14 July 2003 - If you need the most recent working version of this source code with improvements and bug fixes check out my website. www.rubisoftware.com

License

This article, along with any associated source code and files, is licensed under The BSD License

About the Author

sirrube

Web Developer

United States United States

Member

A Software Developer.

Sign Up to vote   Poor Excellent
Add a reason or comment to your vote: x
Votes of 3 or less require a comment

Comments and Discussions

 
You must Sign In to use this message board. (secure sign-in)
 
Search this forum  
 FAQ
    Noise  Layout  Per page   
  Refresh
GeneralHelp for C++ Link error Pinmemberden32319:31 26 Jun '07  
Question"Searchable" PDF format PinmemberAlexsander Antunes0:46 15 Feb '07  
GeneralTIFF G4 file cannot convert to pdf PinmemberAngela2006_200615:06 28 Nov '06  
I get a tiff(g4)file from scanner by CXimage, but converted pdf is blank when it is opened by Acrobat Reader. The file size is correct. Your example is correct. I don't know why. Thank you! My e-mail:lyzlxh@sina.com
 
Angela

GeneralHelp for C++ Novice PinmemberKenny P5:31 27 Mar '06  
GeneralRe: Help for C++ Novice Pinmemberdaqi23:39 27 Sep '06  
QuestionEmbed? PinmemberVasudevan Deepak Kumar4:17 14 Mar '06  
Generalhelp!!! Dont convert more then 1 file Pinmemberyanivo20:43 17 Jul '05  
Generalbmp jpg gif png Pinmemberdonj820:16 26 May '05  
GeneralRe: bmp jpg gif png PinmemberVasudevan Deepak Kumar4:18 14 Mar '06  
Generaltoo big Pinmembercsunny17:52 10 May '05  
QuestionHow about PDF to TIFF PinsussAnonymous15:22 12 Dec '04  
AnswerRe: How about PDF to TIFF Pinmemberdeepak827821:15 8 Feb '05  
GeneralRe: How about PDF to TIFF Pinmemberjmlynn15:49 10 Feb '05  
GeneralRe: How about PDF to TIFF Pinmemberdeepak827820:12 10 Feb '05  
GeneralRe: How about PDF to TIFF PinmemberPaul R.8:14 7 Nov '07  
AnswerRe: How about PDF to TIFF Pinmemberfastal7:55 28 Feb '08  
GeneralCompilation problem Pinmemberksvenkatakrishnan2:15 1 Oct '04  
GeneralRe: Compilation problem PinmemberPandele Florin23:32 17 Apr '05  
GeneralERROR Pinsusspubba18:36 19 Jul '04  
QuestionHow to add bmp file as PDF File Format. Pinsusspubba19:19 18 Jul '04  
QuestionHow to convert from txt to tiff??? PinmemberJigar Mehta20:19 4 Jun '04  
AnswerRe: How to convert from txt to tiff??? Pinmemberal_yakout22:02 4 Jun '04  
GeneralRe: How to convert from txt to tiff??? PinmemberJigar Mehta22:45 4 Jun '04  
GeneralRe: How to convert from txt to tiff??? PinsussAnonymous19:55 5 Jun '04  
GeneralRe: How to convert from txt to tiff??? Pinmemberal_yakout19:56 5 Jun '04  

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Mobile
Web02 | 2.5.120529.1 | Last Updated 18 Feb 2003
Article Copyright 2002 by sirrube
Everything else Copyright © CodeProject, 1999-2012
Terms of Use
Layout: fixed | fluid