将 pdf 文件转换为 tiff 文件的最佳方法

发布于 2024-07-04 03:50:13 字数 98 浏览 5 评论 0原文

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

I have around 1000 pdf filesand I need to convert them to 300 dpi tiff files. What is the best way to do this? If there is an SDK or something or a tool that can be scripted that would be ideal.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(13

宫墨修音 2024-07-11 03:50:13

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

The PDF Focus .Net can do it in such way:

1. PDF to 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 to Multipage-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);
    }
}   
烟若柳尘 2024-07-11 03:50:13

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

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

Disclaimer: work for product I am recommending

Atalasoft has a .NET library that can convert PDF to TIFF -- we are a partner of FOXIT, so the PDF rendering is very good.

梦毁影碎の 2024-07-11 03:50:13

所需的 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')

Required ghostscript & tiffcp
Tested 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')
输什么也不输骨气 2024-07-11 03:50:13

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

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

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

You could also use pdf2ps, ps2image and then convert from the resulting image to tiff with other utilities (I remember 'paul' [paul - Yet another image viewer (displays PNG, TIFF, GIF, JPG, etc.])

愛上了 2024-07-11 03:50:13

也许也尝试这个? PDF Focus

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

Maybe also try this? PDF Focus

This .Net library allows you to solve the problem :)

This code will help (Convert 1000 PDF files to 300-dpi TIFF files 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();
    }
雨巷深深 2024-07-11 03:50:13

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

I like PDFTIFF.com to convert PDF to TIFF, it can handle unlimited pages

人事已非 2024-07-11 03:50:13

使用 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 的手册页,以了解需要哪些确切的选项并进行实验。

Use Imagemagick, or better yet, Ghostscript.

http://www.ibm.com/developerworks/library/l-graf2/#N101C2 has an example for imagemagick:

convert foo.pdf pages-%03d.tiff

http://www.asmail.be/msg0055376363.html has an example for ghostscript:

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

I would install ghostscript and read the man page for gs to see what exact options are needed and experiment.

鱼窥荷 2024-07-11 03:50:13

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

在 Windows 上:

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

on *nix:

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

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

Using GhostScript from the command line, I've used the following in the past:

on Windows:

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

on *nix:

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

For a large number of files, a simple batch/shell script could be used to convert an arbitrary number of files...

_畞蕅 2024-07-11 03:50:13

我编写了一个小 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
    }
}

I wrote a little powershell script to go through a directory structure and convert all pdf files to tiff files using ghostscript. Here is my script:

$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
    }
}
空城仅有旧梦在 2024-07-11 03:50:13

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 文件拖到此文件上会将它们转换为压缩的 TIFF,分辨率为 300 DPI。

1) Install GhostScript

2) Install ImageMagick

3) Create "Convert-to-TIFF.bat" (Windows XP, Vista, 7) and use the following line:

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

Dragging any number of single-page PDF files onto this file will convert them to compressed TIFFs, at 300 DPI.

逆流 2024-07-11 03:50:13

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

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

using python this is what I ended up with

import os
os.popen(' '.join([
                   self._ghostscriptPath + 'gswin32c.exe', 
                   '-q',
                   '-dNOPAUSE',
                   '-dBATCH',
                   '-r300',
                   '-sDEVICE=tiff12nc',
                   '-sPAPERSIZE=a4',
                   '-sOutputFile=%s %s' % (tifDest, pdfSource),
                   ]))
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文