Solved

How can I convert from PDF to tiff using ghostscript?

Posted on 2009-05-12
6
4,576 Views
Last Modified: 2013-12-02
I need to convert some files from pdf to tiff in a vb 2005 application and I heard it's possible with ghostscript. How can I approach this. I use vb but I can translate to c# if necessary.
0
Comment
Question by:JAVI1065
  • 4
6 Comments
 
LVL 20

Accepted Solution

by:
alainbryden earned 500 total points
Comment Utility
BCL Computers' Freebird software is available as a command line program. Freebird converts PDF to TIFF, JPEG, and BMP. For more information, visit our website at http://www.bcl-computers.com. If you use this you don't need to make complicated dll calls.

~Alain
0
 
LVL 20

Expert Comment

by:alainbryden
Comment Utility
Try putting this CMD into the root of your ghostscript installation.

If it doesn't work then maybe ghostscript just can't do it.

~Alain
rem pdf2tif.cmd

rem Convert a pdf to a TIFF

rem Usage: pdf2tif.cmd input.pdf[output.tiff]
 

set GS_HOME=%~dp0

set GSC="%GS_HOME%bin\gsc.exe"

set fileinput=%1

set cmdfile="%GS_HOME%_%~n1.rsp"

if %2/==/ (set fileoutput="%~dp1%~n1%%d.tiff") else (set fileoutput=%2)
 

echo -q -dSAFER -dNOPAUSE -dBATCH > %cmdfile%

echo -sDEVICE#tifflzw -r600 -dTextAlphaBits=4 >> %cmdfile%

echo -dGraphicsAlphaBits=4 >> %cmdfile%

echo -sOutputFile#%fileoutput% -f %fileinput% >> %cmdfile%

%GSC% @%cmdfile%
 

if exist %cmdfile% erase %cmdfile%

Open in new window

0
 
LVL 20

Expert Comment

by:alainbryden
Comment Utility
apparently the following can also work from the command line.

~Alain
gswin32c -dNOPAUSE -q -g300x300 -sDEVICE=tiffg4 -dBATCH -sOutputFile=output_file_name.tif input_file_name.pdf

Open in new window

0
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
LVL 20

Expert Comment

by:alainbryden
Comment Utility
Here's more code that claims it can do the same using ghostscript in powershell:

~Alain
$tiff = $pdf.FullName.split('.')[0] + '.tiff'

if(test-path $tiff)

{

    "tiff file already exists " + $tiff

}

else        

{   

    'Processing ' + $pdf.Name        

        $param = "-sOutputFile=$tiff"

    & $tool -q -dNOPAUSE -sDEVICE=tiffg4 $param -r300 $pdf.FullName -c quit

}

Open in new window

0
 

Expert Comment

by:lglaw
Comment Utility
Here is a simple C# GS wrapper to convert PDF to JPEG which can easily be modified for TIFF:
http://www.mattephraim.com/blog/2009/01/06/a-simple-c-wrapper-for-ghostscript/
Change the sDevice arg from jpeg to tiffg4 (assuming you want black & white).  Lose dTextAlphaBits & dGraphicsAlphaBits.  You can use the -r arg to adjust dpi.
0
 
LVL 2

Author Closing Comment

by:JAVI1065
Comment Utility
I had to change of program
0

Featured Post

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

This article provides the solution to a question (http://www.experts-exchange.com/Software/Photos_Graphics/Images_and_Photos/Q_28674207.html) posed here at Experts Exchange. The asker of the question has many JPG images in many folders, and all of t…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
In this video, we show how to convert an image-only PDF file into a PDF Searchable Image file, that is, a file with both the image (typically from scanning) and text, which is created in an automated fashion with Optical Character Recognition (OCR) …

771 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now