How to convert TIFF to PDF using Ghostscript

1

How can I convert TIFF to PDF using Ghostscript?

I tried to use the code below but it not working:

Snippet

$input_file_tif='test.pdf';
$input_file_orig_name='1234.tiff';
$gs_command = "gs -q -dNOPAUSE -dBATCH -dSAFER -sDEVICE=tiffg3 -r300x300 \
                  -sOutputFile='".$input_file_tif."".$input_file_orig_name."' ";

HP371

Posted 2015-05-19T09:45:43.233

Reputation:

Answers

1

Ghostscript doesn't support TIFF as an input, so you can't immediately use it to turn a TIFF file into a PDF. You might be better to use an image editing application such as ImageMagick.

For anyone who wishes to persist, it is possible to read a TIFF file by writing a PostScript program, which Ghostscript is able to run (because it is a PostScript interpreter). See this question on Stack Overflow:

https://stackoverflow.com/questions/15211428/conversion-tif-to-pdf-ghostscript

KenS

Posted 2015-05-19T09:45:43.233

Reputation: 236

0

Is there any particular reason for using Ghostscript?

If you have gs installed, you very probably also have Image Magick's convert command. This article discusses some aspects of the quality factor and how to maintain a reasonable output size.

Also consider the possibility that, if the input file is technical (i.e. drawings) you might consider tracing the input and doing a conversion to a real vector image, which would create a much smaller PDF.

jcoppens

Posted 2015-05-19T09:45:43.233

Reputation: 629

0

I Convert the Tiff file to Pdf File by use Imagick

code :

$document = new Imagick(test.tiff);

$document->setImageFormat("pdf");

$document->writeImages("test.pdf", true);

HP371

Posted 2015-05-19T09:45:43.233

Reputation: 1