# tiff2pdf – Convert TIFF Files to PDF

Version: 2.0.0

Part of DaVince Tools

Last Modified: December 13, 2001

Command Syntax

Description

Problem TIFF Files

New Features / Changes

Additional Information

About DaVince Tools

## Command Syntax

(Please note that the square brackets "[" and "]" specify optional parameters; do not enter the brackets as part of the command)

tiff2pdf [-1] [-c commandfile] [-f] [-i key:value [-i key:value]] [-o outputfile] [-p profile] [-r] [-s] [-?] [file1 file2 ...] [dir1 dir2 …]

Arguments:

-1: (numeric "one") Create a PDF file for each TIFF file specified on the command line (one to one relationship). For each TIFF file specified, a PDF file is created in the same directory with the same name except with a ".PDF" extension. A PDF file is not created if one already exists and is newer than the corresponding TIFF file. To force a PDF file to be created, use the "-f" option. The default is to take all specified files and combine them into a single PDF file (many to one relationship). The behavior of the "-o" option changes when using the "-1" option, as described below.

-c: Process commands in the specified command file. When using this argument, files and directories can be specified via a file instead of on the command line. Click here for more info on command files.

-f: When used with the "-1" option, force overwriting an existing PDF file. By default, a PDF file may not be created with the "-1" option if the TIFF file is unchanged since the last time the PDF file was created.

-i: Specify Info dictionary attribute values like title and author of document. The following attributes are available for use:

Attribute | Description
Author | The name of the person who created the document.
Keywords | Key words associated with the document.
Subject | The subject of the document.
Title | The title of the document.

Note that the attribute names are case sensitive (first character in uppercase). This option can be specified multiple times when setting multiple dictionary attribute values. To specify an attribute along with its data, separate the two with a colon ":". You will need to enclose the string in quotes if there are spaces in the data. For example, to set the title of a document to "The Declaration of Independence", use the following parameter:

-i "Title:The Declaration of Independence"

In addition to these tags, custom tags can be used with this option; however, Acrobat Reader will not recognize them. The "CreationDate" and "Creator" attributes are automatically filled in by the program and cannot be overridden with this option.

-o: This meaning of this option varies depending on if the "-1" (numeric "one") option is used. When "-1" is used with this option, this specifies an alternate directory to use when creating the PDF files (new in version 1.2). When "-1" is not used with this option, this specifies the file name to use for the newly created PDF file. The ".pdf" extension should be included when specifying a filename. If the "-o" option is not used when "-1" is specified, then by default the PDF file is created in the same directory as the TIFF file. If the "-o" and "-1" options are not used, the filename "tiff.pdf" in the current directory is assumed.

-p: Specify a profile to use in the creation of the PDF file. Profiles contain conversion information such as bookmark and compression settings and reside in the "tiff2pdf.ini" file located in either the directory where the executable file resides or the windows base directory (typically "C:\WINDOWS" for Windows 9x, "C:\WINDIR" for Windows NT). If the file is present in both directories, the file located in the windows base directory takes precedence. The default profile "default" is used when this option is not specified.

-r: When a directory is specified, search subdirectories (recursive search).

-s: Sort the filenames specified on the command line in alphanumeric order before processing them. Note that when a directory is specified on the command line, files in that directory are always sorted.

-?: A brief summary of arguments is displayed.

[file1 file2 …]: Specify one or more TIFF files to convert. Wild card characters such as "*" and "?" may be used. The "-d" parameter can be used in conjunction with this option.

[dir1 dir2 …]: Specify one or more directories to convert. All TIFF files in this directory should end in either ".tif", or ".tiff". Files are converted in alphanumeric order. Use the "-r" option to include subdirectories.

##

## Description

"tiff2pdf" is a command line program that converts TIFF (Tagged Image File Format) files to PDF (Portable Document Format) files. The program can convert a TIFF file by either recompressing the data for PDF use or taking the raw image data from the file "as is" and putting it into a PDF wrapper when possible. This analogous to removing a letter from a letter size envelope and placing it in a business size envelope. The original image data is unaltered, so no data recompression is required (not all TIFF raw image data is compatible with PDF; these files will automatically be recompressed). The key features of this program are:

- TIFF compression modes 1, 2, 3, 4 and 32773 support
- Single and multi-strip file support
- Tiled TIFF file support
- Single and multi-page file support
- Monochrome, grayscale and color (indexed, RGB and CMYK) image support
- Thumbnail and bookmark support
- Convert many TIFF files to one PDF or create a PDF file for each specified TIFF file
- Individual filenames with wildcard support and/or an entire directory may be specified for conversion
- Specify files or directories to convert either via the command line or a command file
- Large file support (1,000+ pages)
- Compatible with Acrobat Capture for OCR conversion of image data
- Creates a version 1.2 PDF file with a unique file ID in trailer
- Quick conversion of data option uses existing compressed image data in PDF file, resulting in faster conversion time
- Archive conversion of data option recompresses image data creating smaller PDF files in many cases

The following TIFF tags are required in order for the file to be converted. If any of these tags are missing, the application will skip over the image. The "tiffdump" program, part of DaVince Tool set, can be used to display the tags of a TIFF file.

ImageLength | The # of scan lines of an image
ImageWidth | The # of pixels in a scan line of an image
Compression | The type of compression used (valid values are: 2 (Modified Huffman), 3 (Group 3) and 4 (Group 4)
StripOffsets/TileOffsets | Array of one or more offsets to image data
StripByteCounts/TileByteCounts | Array of one or more values of lengths pointed to by the StripOffsets tag for stripped images, or TileOffsets for tiled images
TileLength | The # of scan lines in a tile (only required for tiled Tiff images)
TileWidth | The # of pixels in a scan line in a tile (only required for tiled Tiff images)

The following TIFF tags are recognized by tiff2pdf but are not required for a conversion.

NewSubFileType | Used to skip over thumb nail and transparency mask images
Xresolution | The scan resolution in the X direction. If this tag is not present, then either 300 dpi or the resolution specified by the DefaultDPI option is used.
Yresolution | The scan resolution in the Y direction. If this tag is not present, then either 300 dpi or the resolution specified by the DefaultDPI option is used.
ResolutionUnit | Used to specify the XResolution and Yresolution tags are in inches or centimeters (default is ‘inches’ if tag is not present)
BitsPerSample | Number of bits per component.
SamplesPerPixel | The number of components per pixel. SamplesPerPixel is usually 1 for bilevel, grayscale, and palette-color images. SamplesPerPixel is usually 3 for RGB images.
T4Options | Used to determine 1 or 2 dimensional encoding and byte aligned rows for compression type 2.
PhotometricInterpretation | Used to determine if the data is black and white, pallete color, RGB color, CMYK color or grayscale. For black and white data, this also specifies if the zero pixel is either black or white
FillOrder | The program supports the FillOrder tag.

The height, width and resolution tags are used to determine the physical page size. For example, an image 2,544 pixels wide and 3,287 pixels long and scanned at 300 DPI results in a PDF page size of 2,544/300 by 3,287/300, or 8.48 inches wide by 10.96 inches long. The resulting page size may not match a standard paper size, however, this is not a problem for viewers like Adobe Acrobat. The advantage to this method is that a multiple page conversion can contain images scanned at different sizes. This allows, for example, a converted PDF file to contain both U.S. letter and legal size pages, as well as differing European sizes (A1, A2, etc.) or even a combination of the two.

The screen output can be redirected to a file adding the DOS syntax ">filename" to the end of the command line. This can be used to redirect output to a log file. The program returns an error code of 1 when a fatal error occurs, used in batch programs to test the success of the program.

The program options are specified either on the command line or in a profile stored in the initialization file. Command line options are typically file related directives, whereas the profile settings are conversion related directives. Profile settings are stored in the initialization file "tiff2pdf.ini", located in either the executable file's directory or the Windows’ root directory (typically "C:\WINDOWS" for Windows 9x and "C:\WINNT" for Windows NT/2000). If both files are present, the file in the Windows' root directory takes precedence. The file is divided into profiles, which can be specified by name on the command line. A profile begins with the name of the profile surrounded by square brackets. An example file is shown below:

`

[default]

`
`thumbnail=yes`
`bookmark=yes`
`defaultdpi=300`
`compression=yes`

Multiple profiles can exist in the file. The "-p" command line option determines which profile the program will use. Profile names are case sensitive. If no profile is specified on the command line, the default profile ("[default]") is used. Default profile options can be overwritten by defining them in the "_common" profile.

In addition to the default profile, the following sample profiles are defined in the tiff2pdf.ini file that ships with the program:

Profile Name | Description
quick | Best for compression speed, no bookmarks or thumbnails.
quickbookmark | Best for compression speed, with bookmarks.
archive | Best for optimal file size, no bookmarks or thumbnails.
bookmark | Best for optimal file size, with bookmarks.
thumbnail | Best for optimal file size with bookmarks and thumbnails.

Several option statements can appear after the profile line. These option statements have the following syntax:

option=value

Where option is the name of valid option (see below) and "value" is the value for the option. Depending on the option, "value" can be a number, a string or a Boolean value. The following values are all valid for a Boolean value:

Valid True Values | Valid False Values
True, T, On, Enable, Yes, Y | False, F, Off, Disable, No, N

These values are case insensitive (i.e. both "true" and "TRUE" are valid).

### Common Profile Settings

The following table describes options allowed in the tiff2pdf.ini file that are common to all "DaVince Tools" converters (options are case insensitive):

Option | Data Type | Description
Bookmark | Bool | When true, create a bookmark for each file converted
BookmarkFilenameExtension | Bool | When true, include filename extension (usually ".tif" or ".tiff") in the bookmark name. Otherwise, ignore it. The default is false.
Compression | Bool | When true, compress the page description (image data is always compressed). The default value is false.
Description* | Description of Profile (string) | Description of profile. This description is displayed in the Windows version of "DaVince Tools"
FileMatch | String | This parameter allows setting a default file match pattern when specifying a directory to convert. This is a comma delimited list of file matching patterns. The default setting is "*.tif,*.tiff"
OpenAction | Fit, FitH, FitV, None | This parameter describes how to view the first page of the newly created PDF file when opened. Choices are "Fit" to fit entire page, "FitH" to fit the horizontal width of the page, "FitV" to fit the vertical width of the page, or "None", which defaults to the setting defined in the PDF viewer. The default setting is "None".

* - new in version 2.0

### Converter Specific Settings

These tables describe txt2pdf.ini settings that are unique to this converter. They are divided into the following categories:

The following table describes tiff2pdf settings that are unique to this converter (options are case insensitive):

Option | Data Type | Description
Archive* | Bool | When true, compress image data in an optimal manner. When archive option is set to true, converted page indicator is a plus sign ("+"). When archive option is set to false, converted page indicator is a period ("."). Archive mode is automatically turned on for image formats that are not supported natively in PDF (PackBits and CCITT Group 3 with unsupported Group 3 options are examples). The default is false.
DamagedRowCount | Number | This parameter is used when a TIFF file was received from a Group 3 Facsimili device and contains transmission errors. Setting this parameter to a positive number will allow the PDF reader to accept files with damaged rows up to this value. A value of "1" or "2" may be sufficient for most users. This parameter is only used with Group 3 files. Group 4 files are not affected. This option is not used when "archive" is set to true. By default, this value is "0" (no damaged rows allowed).
DefaultDPI | Number (in dpi) | Default resolution to use if resolution tag is not present. Use 300 if this option not present.
FileMatch | String | This parameter allows setting a default file match pattern when specifying a directory to convert. This is a comma delimited list of file matching patterns. The default setting is "*.tif,*.tiff"
Transparency | Bool | When true, make image background transparent, useful with other programs that create watermarks. When false, make image background opaque. If using Acrobat Capture for OCR conversion with the resulting PDF file, this must be set to false. The default value is false.
Thumbnail | Bool | Create thumbnail images. Note that this will increase processing time, even when the "Archive" option is set to false. The default is false.

* - new in version 2.0

## Problem TIFF Files:

Not all TIFF files can be converted with this application. One should verify the correctness of the conversion by viewing the PDF file with a PDF viewer. Listed below are reasons why a TIFF file may not be converted:

- Monochrome, gray scale and color TIFF files with compression mode 1 (uncompressed), 2 (Huffman), 3 (CCITT Group 3), 4 (CCITT Group 4) or 32773 (Packbits), are supported. Mode 5 compression (LZW), typically used for compressing color images, is supported only when "archive" is set to false. Indexed, RGB and CMYK color images are supported. JPEG compressed TIFF files are not supported.
- The following TIFF tags are required: ImageLength, ImageWidth, Compression, StripOffsets/TileOffsets and StripByteCounts/TileByteCounts. Most TIFF reading applications require these tags.
- Starting with version 1.1, the TIFF tag FillOrder is supported. Versions of tiff2pdf prior to version 1.1 will not convert these files.
- Not all CCITT compressed images can be copied to the PDF file unaltered. In particular, compressed images containing the T4Option tag with bit 2 set can not be converted as-is, since there is no equivalent T4 option in the PDF specification. tiff2pdf will recompress this image if it detects this bit is set (Note: releases of tiff2pdf prior to version 2 generated an error). For a technical description about bit 2 in the T4Option tag, the TIFF 6 Specification describes it as follows:

Bit 2 is 1 if fill bits have been added as necessary before EOL codes such that EOL always ends on a byte boundary, thus ensuring an EOL-sequence of 1 byte preceded by a zero nibble: xxxx-0000 0000-0001.

- Certain TIFF files generated with version 1.1.0 of tiff2pdf generated a "Read less image data than expected" error in Acrobat Reader and Exchange. This problem was fixed in version 1.1.1. If you still receive this error when using version 1.1.1 or later of tiff2pdf, then the image data may be at fault. Certain programs (typically older programs) that create TIFF files truncate the bottom of the page if there is no image data to display. Specifying an image height and then storing image data of a lesser height does not conform to industry practices and Acrobat complains about it. tiff2pdf also complains about it when generating a thumbnail for this image. Acrobat still allows viewing and printing of this image despite the error. To remove the error message you should recompress the image data by using a profile with the archive option enabled

## New Features / Changes:

A list of new features and changes, along with a version history, can be found in the release notes.

## Additional Information:

Any DaVince Tool product that creates a PDF must create an intermediate file prior to writing the PDF file. The filename of this intermediate file begins with "tmps" and appears in the directory pointed to by the environment variable "TMP". If this environment does not exist, then the temporary file is written in the current directory. The intermediate file exists only during the execution of the program.

##

## About DaVince Tools:

Visit the DaVince Tools web site at http://www.davince.com for the latest version of this software and the latest documentation. DaVince Tools is shareware and software registration is urged if you find these programs useful. You can register the software on-line at http://www.davince.com.

DaVince Tools

was written in C++ using the DaVince Class Library, written by the same author as this program. The DaVince Class Library is a C++ library for developing PDF and TIFF applications. Contact the author at info@davince.com for more information on the availability of the class library.