Solved

How can I convert from PDF to tiff using ghostscript?

Posted on 2009-05-12
6
4,705 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
6 Comments
 
LVL 20

Accepted Solution

by:
alainbryden earned 500 total points
ID: 24539898
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
ID: 24615881
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
ID: 24615895
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
Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

 
LVL 20

Expert Comment

by:alainbryden
ID: 24615903
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
ID: 24842163
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
ID: 31580683
I had to change of program
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Windows Script Host failed (Access is denied.) error 6 477
Hide vba in gp 7 127
Export Data to Different .csv Files 27 133
Publisher:   Unknown     VB.exe Application 1 31
In a previous article published here at Experts Exchange, Signature Image with Transparent Background (http://www.experts-exchange.com/Web_Development/Document_Imaging/A_12380-Signature-Image-with-Transparent-Background.html), I explained how to cre…
In a previously published article (http://www.experts-exchange.com/articles/10331/Automatic-Duplex-Scanning-in-PaperPort-Versions-11-12-14.html) here at Experts Exchange, I explained how to achieve duplex (double-sided) scanning in Nuance's PaperPor…
This video is the first in a two-part series that discusses PaperPort's "Send To Bar" feature . This first video tutorial explains the purpose of the Send To Bar, how to use it, and how to hide unwanted items that are automatically created on it whe…
In this first video of the three-part Xpdf series, we introduce and describe Xpdf, a library containing nine command line utilities that perform various functions on PDF files. We show where the library is located and how to download it, discuss its…

738 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