Click here to Skip to main content
Email Password   helpLost your password?

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

You must Sign In to use this message board.
 
 
Per page   
 FirstPrevNext
GeneralHelp for C++ Link error
den323
20:31 26 Jun '07  
I have downloaded the entire CxImage project and built it . and then I downloaded this project open the work space and clicked build.. I keep getting the following..

LINK : fatal error LNK1104: can not open "dlibtiff.lib"

Any suggestions on how to get this to work or what I might be doing incorrectly? Thanks..


Question"Searchable" PDF format
Alexsander Antunes
1:46 15 Feb '07  
This generate "Searchable" PDF format?

Alexsander "Axia" Antunes

GeneralTIFF G4 file cannot convert to pdf
Angela2006_2006
16: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
Kenny P
6:31 27 Mar '06  
Ok.. I'm a C++ novice so any basic help here would be greatly appreciated. I have downloaded the entire CxImage project and built it (c:\cximiage local) and then I downloaded this project open the work space and clicked build.. I keep getting the following..

tdAfx.cpp
c:\codeproject\wrk\tifftopdf\stdafx.h(22) : fatal error C1083: Cannot open include file: 'tiffio.h': No such file or directory
Error executing cl.exe.

TiFFToPdf.exe - 1 error(s), 0 warning(s)

Any suggestions on how to get this to work or what I might be doing incorrectly? Thanks..

KP
GeneralRe: Help for C++ Novice
daqi
0:39 28 Sep '06  
You may read the readthis.txt firstly.
That's to set the include path to TiffLib where tiffio.h resides.
GeneralEmbed?
Vasudevan Deepak Kumar
5:17 14 Mar '06  
Tiff is a image format right? And I think PDF can support image embedding. http://www.itextsharp.sourceforge.net/[^] can also support image embedding.

Vasudevan Deepak Kumar
Personal Web: http://www.lavanyadeepak.tk/ I Blog At:
http://www.dotnetjunkies.com/weblog/deepak/
http://deepakvasudevan.blogspot.com/
http://deepak.blogdrive.com/
Generalhelp!!! Dont convert more then 1 file
yanivo
21:43 17 Jul '05  
hello,
I was compiled as dll
when i try to call it one time its ok
but when i loop through some tiff files in the second tiff
it's failed convert to pdf file Cry

any help ???? Confused Confused
Generalbmp jpg gif png
donj82
1:16 26 May '05  
hi can u code add bmp jpg gif png format to pdf
GeneralRe: bmp jpg gif png
Vasudevan Deepak Kumar
5:18 14 Mar '06  
Check out this http://www.codeproject.com/file/tifftopdf.asp?df=100&forumid=13464&select=1407234&msg=1407234#xxxx[^]



Vasudevan Deepak Kumar
Personal Web: http://www.lavanyadeepak.tk/ I Blog At:
http://www.dotnetjunkies.com/weblog/deepak/
http://deepakvasudevan.blogspot.com/
http://deepak.blogdrive.com/
Generaltoo big
csunny
18:52 10 May '05  
The result pdf file is too big. How to reduce the size?

GeneralHow about PDF to TIFF
Anonymous
16:22 12 Dec '04  
I have a need to take a PDF file and conver it to a TIFF, if there are multiple pages, it'd make a multipage TIFF. Any idea if this could do the reversal of what it is doing now? Has anyone else done this before with .NET? Any ideas where to look for starters?
GeneralRe: How about PDF to TIFF
deepak8278
22:15 8 Feb '05  
Yep, the same thing that you need is available at Code Guru at following url Laugh

http://www.codeguru.com/Cpp/G-M/bitmap/otherformats/article.php/c4933__1

I hope this helps Roll eyes


~ Deepak Gupta
GeneralRe: How about PDF to TIFF
jmlynn
16:49 10 Feb '05  
I visited the link, it seems to shows how to save TIFF to PDF, in the TIFF2PDF function, not PDF2TIFF function.

Is the link the right link?

jml
GeneralRe: How about PDF to TIFF
deepak8278
21:12 10 Feb '05  
Hi,

I think there is no FREE tool available to convert PDF to TIFF.:( Still you may try the following links, may be useful:

// .NET based article
http://www.codeproject.com/showcase/TallComponents.asp

//Trial Application
http://www.verypdf.com/pdf2tif/


Hope this helps.

~ Deepak Gupta
GeneralRe: How about PDF to TIFF
Paul R.
9:14 7 Nov '07  
You can take a look at GraphicsMagick on Sourceforge. It has a robust collection of tools and libraries which support reading, writing, and manipulating an image in over 88 major formats. It has a c++ wrapper you can use to call the library from within a program.

The formats are listed here: http://www.graphicsmagick.org/www/formats.html If you have Ghostscript installed on the PC you can convert a tiff to a PDF or a PDF to a Tiff file. Not sure about Ghostscript licensing requirements but the GraphicsMagick license allows commercial use as long as you follow their few requirements.

Hope this helps out...Smile

Paul R.

I haven't lost my mind,
it's backed up on tape somewhere...(I think?)

AnswerRe: How about PDF to TIFF
fastal
8:55 28 Feb '08  
Use Ghostscript. Install it. To convert a PDF to TIFF, use this command line:

"C:\Program Files\gs\gs8.51\bin\gswin32.exe"
-dSAFER -dBATCH -dNOPAUSE -sDEVICE=tifflzw -r300
-sOutputFile="C:\TEMP\OUTFILE.TIFF" "C:\TEMP\INPUT.PDF"

Latest version of GhostScript is free if you call it as an EXE, and your program can run in some capacity without it. Check the license for sure. Older versions, if you can find them, have a more liberal license.
GeneralCompilation problem
ksvenkatakrishnan
3:15 1 Oct '04  
I downloaded the source from the site and compiled it. On compilation, it gave an error message

"D:\TWAIN\cpTifftopdf\codeproject\wrk\TiFFToPdf\TiFFToPdf.cpp(6) : fatal error C1083: Cannot open include file: 'lisa2tiff.h': No such file or directory"

Could somebody let me know where i can find this file or any workaround for this problem.

Thanks in advance for your help
GeneralRe: Compilation problem
Pandele Florin
0:32 18 Apr '05  
Remove the #include clause Smile
The file is not actually needed
GeneralERROR
pubba
19:36 19 Jul '04  
hi,
When I am going to convert slide1.tiff using "TiFFToPdf.exe" ,appearing a Error....
The Complete error like this:-
"Debug Error,
program: D:\cpTifftopdf\codeproject\wrk\_bin\debug\TiFFToPdf.exe
DAMAGE:after normal block (#88) at 0x00AF0040.
"
Can u please help me:(
GeneralHow to add bmp file as PDF File Format.
pubba
20:19 18 Jul '04  
Hi everybody,
I want to export bmp files as PDF File format.
I have created GDI+ bmp Objects like this.
Bitmap bmp7(L"myImage.jpg");

Now I want to save this bmp7 Object as PDF File format.
Can u or any body please help me...
Thanks.
GeneralHow to convert from txt to tiff???
Jigar Mehta
21:19 4 Jun '04  
Hye, How to convert any text file from TIFF file??? Any idea???

Rose

Jigar Mehta
(jigarmehta@gatescorp.com)

Software Developer
Gates Information Systems
GeneralRe: How to convert from txt to tiff???
al_yakout
23:02 4 Jun '04  
if you want to convet text to tiff it is so easy but tiff to test you need ocr code or program to do it
GeneralRe: How to convert from txt to tiff???
Jigar Mehta
23:45 4 Jun '04  
No, I want to just convert TEXT to TIFF for later processing.. Later processing code is ready.. I want to know how to convert the TEXT to TIFF only?? Plese tell me that easy way...

Rose

Jigar Mehta
(jigarmehta@gatescorp.com)

Software Developer
Gates Information Systems
GeneralRe: How to convert from txt to tiff???
Anonymous
20:55 5 Jun '04  
the easy way to convert text to tiff without any equations or algorithems algorithm you can paint the text as image and then use any code to convet this image to tiff and this code you will found it in codeproject
GeneralRe: How to convert from txt to tiff???
al_yakout
20:56 5 Jun '04  
the easy way to convert text to tiff without any equations or algorithems algorithm you can paint the text as image and then use any code to convet this image to tiff and this code you will found it in codeproject


Last Updated 18 Feb 2003 | Advertise | Privacy | Terms of Use | Copyright © CodeProject, 1999-2010