Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to convert a multi-page PDF to single-page TIFFs

This thread asks for how to convert multi-page PDF to multi-page TIFF with Ghostscript;

  • "Tools to convert multipage PDF to multipage TIFF"

However, I want to covert a multi page PDF to a number of single-page TIFFs: Each page in the PDF is expected to be converted to a single TIFF file. So the above answer does not exactly match what I need.

How can I achieve this?

I am using Windows XP.

like image 758
Changwang Zhang Avatar asked Feb 17 '15 19:02

Changwang Zhang


1 Answers

Be sure to have a recent version of Ghostscript installed. Then you can run these commands:

gs                              \
  -o singlepage-tiffg4-%03d.tif \
  -sDEVICE=tiffg4               \
   multipage-input.pdf

and

gs                                \
  -o singlepage-tiff24nc-%03d.tif \
  -sDEVICE=tiff24nc               \
   multipage-input.pdf

and

gs                                \
  -o singlepage-tiff32nc-%03d.tif \
  -sDEVICE=tiff32nc               \
   multipage-input.pdf

The commands will generate you 3 sets of TIFF files. Each set contains singlepage TIFFs which carry names that contain an index numbers starting with 001:

ls -lt singlepage-tiff*.tif

 -rw-r--r--  1 kp  staff  161975 18 Feb 15:49 singlepage-tiffg4-001.tif
 -rw-r--r--  1 kp  staff  169294 18 Feb 15:49 singlepage-tiffg4-002.tif
 -rw-r--r--  1 kp  staff  167397 18 Feb 15:49 singlepage-tiffg4-003.tif
 -rw-r--r--  1 kp  staff  190052 18 Feb 15:49 singlepage-tiffg4-004.tif

If you have a lot of PDF pages per file, you can increase the number of digits/leading zeros to a higher number: use %05d to get a 5 digit numbering.

The three different commands generate different types of TIFF:

  1. The tiffg4 ones are grayscale TIFFs.
    They use a resolution of 204dpi by 196dpi (as the TIFF G4 fax standard requires).
  2. The tiff24nc ones are in RGB color (with 8 bits per color component).
    They use a resolution of 72dpi by 72dpi.
  3. The tiff32nc ones are in CMYK color (with 8 bits per color).
    They also use a resolution of 72dpi.

All the resolution values for the TIFF files result from Ghostscript's default settings. If you want to override these, for example because you require 600dpi by 600dpi, just add

-r600x600

to any of the above command lines.

like image 94
Kurt Pfeifle Avatar answered Oct 17 '22 05:10

Kurt Pfeifle