Click here to Skip to main content
15,885,546 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 458.2K   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: about Acrobat 6.0 Pin
KW-Rix30-May-05 19:11
KW-Rix30-May-05 19:11 
GeneralRe: about Acrobat 6.0 Pin
bioan6-Mar-07 23:13
professionalbioan6-Mar-07 23:13 
GeneralRe: about Acrobat 6.0 Pin
mohanad19833-Feb-09 0:04
mohanad19833-Feb-09 0:04 
GeneralPDf to Text Pin
Amol Jaysingpure10-Dec-03 20:13
Amol Jaysingpure10-Dec-03 20:13 
GeneralRe: PDf to Text Pin
vlora9-Dec-04 21:50
vlora9-Dec-04 21:50 
GeneralDown load problem Pin
Digissoft2-Dec-03 0:41
Digissoft2-Dec-03 0:41 
GeneralRe: Down load problem Pin
sirrube2-Dec-03 8:01
sirrube2-Dec-03 8:01 
GeneralI found a DLL based on it (support multi-tiff) Pin
Huaiqing29-Sep-03 22:33
Huaiqing29-Sep-03 22:33 
I found a DLL with source code based on it, support multi-tiff format, and it is not expensive.
GeneralRe: I found a DLL based on it (support multi-tiff) Pin
Anonymous1-Oct-03 6:35
Anonymous1-Oct-03 6:35 
GeneralRe: I found a DLL based on it (support multi-tiff) Pin
sirrube1-Oct-03 6:44
sirrube1-Oct-03 6:44 
GeneralRe: I found a DLL based on it (support multi-strp tiff) , visit www.friendsoft.net for more details Pin
Huaiqing1-Oct-03 21:40
Huaiqing1-Oct-03 21:40 
GeneralConvert Tiff To Pdf Pin
ss sivan3-Sep-03 2:41
ss sivan3-Sep-03 2:41 
GeneralRe: Convert Tiff To Pdf Pin
sirrube3-Sep-03 5:37
sirrube3-Sep-03 5:37 
Generalmulti Tiff Error Pin
wxzhao24-Jul-03 21:57
wxzhao24-Jul-03 21:57 
QuestionDLL anybody? Pin
avivas15-Jul-03 11:16
avivas15-Jul-03 11:16 
AnswerRe: DLL anybody? Pin
sirrube15-Jul-03 11:36
sirrube15-Jul-03 11:36 
GeneralAwesome Pin
Anonymous15-Jul-03 9:26
Anonymous15-Jul-03 9:26 
GeneralPrinting the converted file Pin
Jaiprakash25-Jun-03 11:06
Jaiprakash25-Jun-03 11:06 
GeneralRe: Printing the converted file Pin
sirrube26-Jun-03 6:39
sirrube26-Jun-03 6:39 
GeneralConvert Text To Pdf Pin
ali seifi12-May-03 4:13
ali seifi12-May-03 4:13 
GeneralRe: Convert Text To Pdf Pin
Takeru Koushirou10-Jun-03 23:33
Takeru Koushirou10-Jun-03 23:33 
GeneralCompress PDF Pin
schiefiix1-Apr-03 4:14
schiefiix1-Apr-03 4:14 
GeneralRe: Compress PDF Pin
Takeru Koushirou10-Jun-03 23:47
Takeru Koushirou10-Jun-03 23:47 
GeneralDLL Pin
andrewtheraver1-Apr-03 4:09
andrewtheraver1-Apr-03 4:09 
GeneralPb convert PDF Pin
Member 1547126-Mar-03 23:59
Member 1547126-Mar-03 23:59 

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.