Il modo migliore per convertire file pdf in file tiff [chiuso]
Domanda
Ho circa 1000 file pdf e devo convertirli in file tiff da 300 dpi.Qual è il modo migliore per farlo?Se esiste un SDK o qualcosa del genere o uno strumento che può essere creato tramite script, sarebbe l'ideale.
Soluzione
Usa Imagemagick o, meglio ancora, Ghostscript.
http://www.ibm.com/developerworks/library/l-graf2/#N101C2 ha un esempio per imagemagick:
convert foo.pdf pages-%03d.tiff
http://www.asmail.be/msg0055376363.html ha un esempio per ghostscript:
gs -q -dNOPAUSE -sDEVICE=tiffg4 -sOutputFile=a.tif foo.pdf -c quit
Vorrei installare ghostscript e leggere la pagina man di gs per vedere quali opzioni esatte sono necessarie e sperimentare.
Altri suggerimenti
Utilizzando GhostScript dalla riga di comando, in passato ho utilizzato quanto segue:
Su Windows:
gswin32c -dNOPAUSE -q -g300x300 -sDEVICE=tiffg4 -dBATCH -sOutputFile=output_file_name.tif input_file_name.pdf
su *nix:
gs -dNOPAUSE -q -g300x300 -sDEVICE=tiffg4 -dBATCH -sOutputFile=output_file_name.tif input_file_name.pdf
Per un gran numero di file, è possibile utilizzare un semplice script batch/shell per convertire un numero arbitrario di file...
Ho scritto un piccolo script PowerShell per passare attraverso una struttura di directory e convertire tutti i file pdf in file tiff utilizzando ghostscript.Ecco la mia sceneggiatura:
$tool = 'C:\Program Files\gs\gs8.63\bin\gswin32c.exe'
$pdfs = get-childitem . -recurse | where {$_.Extension -match "pdf"}
foreach($pdf in $pdfs)
{
$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
}
}
1) Installa GhostScript
2) Installa ImageMagick
3) Crea "Convert-to-TIFF.bat" (Windows XP, Vista, 7) e utilizza la seguente riga:
for %%f in (%*) DO "C:\Program Files\ImageMagick-6.6.4-Q16\convert.exe" -density 300 -compress lzw %%f %%f.tiff
Trascinando un numero qualsiasi di file PDF a pagina singola su questo file li convertirai in TIFF compressi, a 300 DPI.
usando Python questo è ciò che ho ottenuto
import os
os.popen(' '.join([
self._ghostscriptPath + 'gswin32c.exe',
'-q',
'-dNOPAUSE',
'-dBATCH',
'-r300',
'-sDEVICE=tiff12nc',
'-sPAPERSIZE=a4',
'-sOutputFile=%s %s' % (tifDest, pdfSource),
]))
PDF Focus .Net può farlo in questo modo:
1. Da PDF a TIFF
SautinSoft.PdfFocus f = new SautinSoft.PdfFocus();
string pdfPath = @"c:\My.pdf";
string imageFolder = @"c:\images\";
f.OpenPdf(pdfPath);
if (f.PageCount > 0)
{
//Save all PDF pages to image folder as tiff images, 200 dpi
int result = f.ToImage(imageFolder, "page",System.Drawing.Imaging.ImageFormat.Tiff, 200);
}
2. Da PDF a TIFF multipagina
//Convert PDF file to Multipage TIFF file
SautinSoft.PdfFocus f = new SautinSoft.PdfFocus();
string pdfPath = @"c:\Document.pdf";
string tiffPath = @"c:\Result.tiff";
f.OpenPdf(pdfPath);
if (f.PageCount > 0)
{
f.ToMultipageTiff(tiffPath, 120) == 0)
{
System.Diagnostics.Process.Start(tiffPath);
}
}
Anche ABCPDF può farlo: controlla http://www.websupergoo.com/helppdf6net/default.html
Ghostscript e tiffcp richiesti testati in ubuntu
import os
def pdf2tiff(source, destination):
idx = destination.rindex('.')
destination = destination[:idx]
args = [
'-q', '-dNOPAUSE', '-dBATCH',
'-sDEVICE=tiffg4',
'-r600', '-sPAPERSIZE=a4',
'-sOutputFile=' + destination + '__%03d.tiff'
]
gs_cmd = 'gs ' + ' '.join(args) +' '+ source
os.system(gs_cmd)
args = [destination + '__*.tiff', destination + '.tiff' ]
tiffcp_cmd = 'tiffcp ' + ' '.join(args)
os.system(tiffcp_cmd)
args = [destination + '__*.tiff']
rm_cmd = 'rm ' + ' '.join(args)
os.system(rm_cmd)
pdf2tiff('abc.pdf', 'abc.tiff')
Che ne dici di pdf2tiff? http://python.net/~gherman/pdf2tiff.html
http://python.net/~gherman/projects/pdf2tiff/
Potresti anche usare pdf2ps, ps2image e poi convertire l'immagine risultante in tiff con altre utilità (ricordo 'paul' [paul - Yet another image viewer (visualizza PNG, TIFF, GIF, JPG, ecc.])
Disclaimer:lavorare per il prodotto che sto consigliando
Atalasoft ha una libreria .NET che può farlo convertire PDF in TIFF -- siamo partner di FOXIT, quindi il rendering del PDF è molto buono.
Magari provare anche questo? Focus sul PDF
Questa libreria .Net ti consente di risolvere il problema :)
Questo codice aiuterà (Convertire 1000 file PDF in file TIFF da 300 dpi in C#):
SautinSoft.PdfFocus f = new SautinSoft.PdfFocus();
string[] pdfFiles = Directory.GetFiles(@"d:\Folder with 1000 pdfs\", "*.pdf");
string folderWithTiffs = @"d:\Folder with TIFFs\";
foreach (string pdffile in pdfFiles)
{
f.OpenPdf(pdffile);
if (f.PageCount > 0)
{
//save all pages to tiff files with 300 dpi
f.ToImage(folderWithTiffs, Path.GetFileNameWithoutExtension(pdffile), System.Drawing.Imaging.ImageFormat.Tiff, 300);
}
f.ClosePdf();
}
Mi piace PDFTIFF.com a convertire PDF in TIFF, può gestire pagine illimitate