Click here to Skip to main content
15,881,173 members
Articles / Desktop Programming / MFC
Article

Convert Tiff To Pdf

Rate me:
Please Sign up or sign in to vote.
4.41/5 (15 votes)
17 Feb 2003BSD2 min read 457.7K   14.2K   89   109
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


Written By
Web Developer
United States United States
A Software Developer.

Comments and Discussions

 
GeneralRe: Problem with color TIFF Pin
sirrube13-Feb-03 6:50
sirrube13-Feb-03 6:50 
QuestionDoes anybody have a compiled dll of this code? Pin
HerculesSteel12-Feb-03 8:11
HerculesSteel12-Feb-03 8:11 
GeneralAcrobat Error - Insufficient Data for An Image Pin
cosmin11-Feb-03 22:22
cosmin11-Feb-03 22:22 
GeneralRe: Acrobat Error - Insufficient Data for An Image Pin
sirrube12-Feb-03 6:14
sirrube12-Feb-03 6:14 
GeneralRe: Acrobat Error - Insufficient Data for An Image Pin
Sina Falahati16-Jul-03 3:20
Sina Falahati16-Jul-03 3:20 
Generalcimaged.lib Pin
sirrube6-Feb-03 17:01
sirrube6-Feb-03 17:01 
Generalcimaged.lib Pin
codesheng6-Feb-03 14:20
codesheng6-Feb-03 14:20 
GeneralRe: cimaged.lib Pin
Christian Graus6-Feb-03 14:56
protectorChristian Graus6-Feb-03 14:56 
GeneralRe: cimaged.lib Pin
codesheng6-Feb-03 16:09
codesheng6-Feb-03 16:09 
GeneralRe: cimaged.lib Pin
sirrube6-Feb-03 17:01
sirrube6-Feb-03 17:01 
GeneralUpdate Released Pin
sirrube5-Feb-03 10:52
sirrube5-Feb-03 10:52 
GeneralRe: Update Released Pin
huso29-May-03 4:58
huso29-May-03 4:58 
GeneralImage is not in fax format. Pin
jsanjosembet.es31-Jan-03 1:14
jsanjosembet.es31-Jan-03 1:14 
GeneralRe: Image is not in fax format. Pin
sirrube6-Feb-03 7:47
sirrube6-Feb-03 7:47 
GeneralUpdate coming soon Pin
sirrube30-Jan-03 10:23
sirrube30-Jan-03 10:23 
GeneralRe: Update coming soon Pin
jsanjosembet.es3-Feb-03 1:22
jsanjosembet.es3-Feb-03 1:22 
GeneralProblem linking Pin
jsanjosembet.es30-Jan-03 5:34
jsanjosembet.es30-Jan-03 5:34 
GeneralRe: Problem linking Pin
jsanjosembet.es30-Jan-03 5:51
jsanjosembet.es30-Jan-03 5:51 
GeneralMore infos Pin
Paolo Bardella29-Jan-03 22:14
Paolo Bardella29-Jan-03 22:14 
GeneralRe: More infos Pin
Obliterator30-Jan-03 6:04
Obliterator30-Jan-03 6:04 
GeneralHaving problem compiling Pin
zzzyzx24-Jan-03 9:36
zzzyzx24-Jan-03 9:36 
GeneralRe: Having problem compiling Pin
machiav29-Jan-03 23:15
machiav29-Jan-03 23:15 
Generalhelp me, pls Pin
hohuy30-Dec-02 17:57
hohuy30-Dec-02 17:57 
GeneralHello Pin
Anonymous4-Dec-02 11:40
Anonymous4-Dec-02 11:40 
GeneralRe: Hello Pin
Christian Graus4-Dec-02 11:47
protectorChristian Graus4-Dec-02 11:47 

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

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