将 pdf 文件转换为 tiff 文件的最佳方法[已关闭]

问题描述 投票:0回答:13

我有大约 1000 个 pdf 文件,我需要将它们转换为 300 dpi tiff 文件。做这个的最好方式是什么?如果有一个 SDK 或可以编写脚本的东西或工具那就是理想的。

pdf image tiff
13个回答
73
投票

使用 Imagemagick,或者更好的是 Ghostscript。

http://www.ibm.com/developerworks/library/l-graf2/#N101C2 有一个 imagemagick 的示例:

convert foo.pdf pages-%03d.tiff

http://www.asmail.be/msg0055376363.html有一个ghostscript的示例:

gs -q -dNOPAUSE -sDEVICE=tiffg4 -sOutputFile=a.tif foo.pdf -c quit

我会安装 Ghostscript 并阅读 gs 的手册页,看看需要哪些确切的选项并进行实验。


45
投票

从命令行使用 GhostScript,我过去使用过以下命令:

在 Windows 上:

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

在*nix上:

gs -dNOPAUSE -q -g300x300 -sDEVICE=tiffg4 -dBATCH -sOutputFile=output_file_name.tif input_file_name.pdf

对于大量文件,可以使用简单的批处理/shell 脚本来转换任意数量的文件...


19
投票

我编写了一个小 powershell 脚本来遍历目录结构并使用 Ghostscript 将所有 pdf 文件转换为 tiff 文件。这是我的脚本:

$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
    }
}

9
投票

1) 安装 GhostScript

2)安装ImageMagick

3) 创建“Convert-to-TIFF.bat”(Windows XP、Vista、7)并使用以下行:

for %%f in (%*) DO "C:\Program Files\ImageMagick-6.6.4-Q16\convert.exe" -density 300 -compress lzw %%f %%f.tiff

将任意数量的单页 PDF 文件拖到此文件上,会将它们转换为 300 DPI 的压缩 TIFF。


7
投票

使用 python 这就是我最终得到的

import os
os.popen(' '.join([
                   self._ghostscriptPath + 'gswin32c.exe', 
                   '-q',
                   '-dNOPAUSE',
                   '-dBATCH',
                   '-r300',
                   '-sDEVICE=tiff12nc',
                   '-sPAPERSIZE=a4',
                   '-sOutputFile=%s %s' % (tifDest, pdfSource),
                   ]))

4
投票

PDF Focus .Net 可以这样做:

1. PDF 转 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. PDF 到多页-TIFF

//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);
    }
}   

3
投票

3
投票

ABCPDF 也可以这样做——查看 http://www.websupergoo.com/helppdf6net/default.html


2
投票

免责声明:为我推荐的产品工作

Atalasoft 有一个 .NET 库,可以将 PDF 转换为 TIFF——我们是 FOXIT 的合作伙伴,所以 PDF 渲染非常好。


2
投票

所需的 Ghostscript 和 tiffcp 在 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')

2
投票

也许也试试这个? PDF 焦点

这个.Net库可以让你解决这个问题:)

此代码将有所帮助(在 C# 中将 1000 个 PDF 文件转换为 300 dpi TIFF 文件):

    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();
    }

2
投票

https://pypi.org/project/pdf2tiff/

您还可以使用 pdf2ps、ps2image,然后使用其他实用程序将生成的图像转换为 tiff(我记得“paul”[paul - 另一种图像查看器(显示 PNG、TIFF、GIF、JPG 等])


1
投票

我喜欢 PDFTIFF.com 将 PDF 转换为 TIFF,它可以处理无限的页面

© www.soinside.com 2019 - 2024. All rights reserved.