使用Ghostscript将TIFF转换为PDF
您能告诉我如何使用Ghostscript或Postscript将TIFF转换为PDF吗 我尝试使用此命令:使用Ghostscript将TIFF转换为PDF,pdf,tiff,ghostscript,postscript,Pdf,Tiff,Ghostscript,Postscript,您能告诉我如何使用Ghostscript或Postscript将TIFF转换为PDF吗 我尝试使用此命令: gswin32c.exe -dBATCH -dNOPAUSE -sDEVICE=pdfwrite -sOutputFile=o.pdf test.tif 但它不起作用 它会产生一个错误: GPL Ghostscript 9.06 (2012-08-08) Copyright (C) 2012 Artifex Software, Inc. All rights reserved. Thi
gswin32c.exe -dBATCH -dNOPAUSE -sDEVICE=pdfwrite -sOutputFile=o.pdf test.tif
但它不起作用
它会产生一个错误:
GPL Ghostscript 9.06 (2012-08-08)
Copyright (C) 2012 Artifex Software, Inc. All rights reserved.
This software comes with NO WARRANTY: see the file PUBLIC for details.
Error: /undefined in II*
Operand stack:
Execution stack:
%interp_exit .runexec2 --nostringval-- --nostringval-- --nostringval-- 2 %stopped_push --nostringval-- --nostringval-- --nostringval-- false 1 %stopped_push 1910 1 3 %oparray_pop 1909 1 3 %oparray_pop 1893 1 3 %oparray_pop 1787 1 3 %oparray_pop --nostringval-- %errorexec_pop .runexec2 --nostringval-- --nostringval-- --nostringval-- 2 %stopped_push --nostringval--
Dictionary stack:
--dict:1169/1684(ro)(G)-- --dict:0/20(G)-- --dict:77/200(L)--
Current allocation mode is local
Current file position is 4
GPL Ghostscript 9.06: Unrecoverable error, exit code 1
GPL Ghostscript 9.06(2012-08-08)
版权所有(C)2012 Artifex Software,Inc.保留所有权利。
此软件不提供保修:有关详细信息,请参阅公共文件。
错误:/II中未定义*
操作数堆栈:
执行堆栈:
%interp_exit.runexec2--nostringval--nostringval--2%停止推送--nostringval--nostringval--false 1%停止推送1910 13%oparray_pop 1909 13%oparray_pop 1893 13%oparray_pop 1787 13%oparray_pop--nostringval--%errorexec_pop.runexec2--nostringval--nostringval--nostringval--2%停止推送--nostringval--
字典堆栈:
--第1169/1684(ro)(G)条——第0/20(G)条——第77/200(L)条--
当前的分配模式是本地的
当前文件位置为4
GPL Ghostscript 9.06:不可恢复的错误,退出代码1
Ghostscript读取PDF和PostScript作为输入,它不读取图像格式,特别是不读取TIFF。但是,PostScript是一种编程语言,因此完全可以编写PostScript程序来读取TIFF文件(随Ghostscript提供的viewgif.ps和viewjpeg.ps程序用于GIF和JPEG格式)
我有一个程序可以做到这一点,并且已经在comp.lang.postscript上发布了几次。这里的共享空间很大(33Kb),但如果您感兴趣,我可以通过电子邮件给您发送一份副本。我使用ubuntu上的Java将PDF文件转换为Tiff文件
代码片段: String convertCommand=“gs-dNOPAUSE-q-sDEVICE=tiff24nc-sCompression=lzw-dBATCH-sOutputFile=“+outputFile+”+sourceFile
Runtime rt=Runtime.getRuntime()
进程pr=rt.exec(convertCommand)
pr.waitFor() 如果需要压缩,只需将命令替换为,
String convertCommand=“gs-dNOPAUSE-q-sDEVICE=tifflzw-dBATCH-sOutputFile=“+outputFile+”“+sourceFile 请在使用之前安装Ghostscript,
1.sudo apt get install ghostscript libtiff tools使用该实用程序。它是为地理空间光栅图像设计的,但它不在乎它是否只是一个普通图像
gdal_translate -of pdf \path\to\someimage.tif test.pdf
有关geo pdf驱动程序及其选项的其他信息:
应用的默认压缩是DEFLATE,这很好,因为它是无损的,但不会生成非常小的文件。通常使用预测器和平铺选项可以增加压缩(但并非总是使用数据进行测试)
对于最小的文件,请使用JPEG。对于最小和最小损耗的组合,请使用JPEG2000,但在客户端的pdf阅读器中进行测试,因为支持不是通用的(最新的Adobe reader可以)
-co
为简洁起见,可与--config
互换。
第一个示例中的大写字母仅为约定,在命令行中这并不重要。
^
是用于抑制换行的Windows字符,当所有字符都在一行中时忽略
Otaining预构建二进制文件:
如果您对地理信息系统一无所知,那么弄清楚要使用哪个分发包将有点痛苦。如果您只想在某个地方填充程序并运行它,请从GIS Internals,2015年1月32位稳定版本中获取“单zip编译的二进制文件”,解包并从
SDKShell.bat开始
我使用Imagick将Tiff文件转换为Pdf文件
代码:
$document = new Imagick(test.tiff);
$document->setImageFormat("pdf");
$document->writeImages("test.pdf", true);
libtiff
软件包(可在所有主要操作系统平台上使用)附带一个名为tiff2pdf
的命令行工具
$ tiff2pdf -h
LIBTIFF, Version 4.0.3
Copyright (c) 1988-1996 Sam Leffler
Copyright (c) 1991-1996 Silicon Graphics, Inc.
usage: tiff2pdf [options] input.tiff
options:
-o: output to file name
-j: compress with JPEG
-z: compress with Zip/Deflate
-q: compression quality
-n: no compressed data passthrough
-d: do not compress (decompress)
-i: invert colors
-u: set distance unit, 'i' for inch, 'm' for centimeter
-x: set x resolution default in dots per unit
-y: set y resolution default in dots per unit
-w: width in units
-l: length in units
-r: 'd' for resolution default, 'o' for resolution override
-p: paper size, eg "letter", "legal", "A4"
-F: make the tiff fill the PDF page
-f: set PDF "Fit Window" user preference
-e: date, overrides image or current date/time default, YYYYMMDDHHMMSS
-c: sets document creator, overrides image software default
-a: sets document author, overrides image artist default
-t: sets document title, overrides image document name default
-s: sets document subject, overrides image image description default
-k: sets document keywords
-b: set PDF "Interpolate" user preference
-h: usage
因此,获取PDF的一个简单命令是:
$ tiff2pdf -o output.pdf -p A4 -F test.tif
到目前为止,我使用的最好的工具是Irfanview。它让我们可以制作一个非常模糊的TIFF文件版本,也让我们可以进行混合TIFF到PDF的转换,其中有些页面是灰度的,有些是彩色的,有些是CCITT4传真编码的 我创建了一个.NET程序,该程序使用以下命令行使用Irfanview转换了数百万个文档: C:\Program Files(x86)\IrfanView\i_view32.exe tiffile.tiff/convert=outputpdfile.pdf/silent/cmdexit NET程序实际上只是将完整路径传递到TIFF输入和PDF输出文件 设置 下载Irfanview 32位。并非所有插件都适用于64位版本,所以我使用了32位 然后下载Irfanview的插件包并安装它 然后打开Irfanview,您需要通过进入文件>>批转换/重命名来定义IMPdf插件(仅限传统32位插件)或更新的PDF插件的设置 批处理转换/重命名窗口中的设置在程序的每次后续执行中保持有效,因为它们存储在Irfanview INI文件中 单击输出格式,然后选择PDF 然后单击选项按钮。这将允许您控制输入TIFF文件转换为PDF时的参数 然后尝试irfanview对一些TIFF文件手动执行此操作,以确保输出符合要求
然后,您可以使用一个程序将其自动化…使用有趣的搜索字符串“ken read tiff”找到一个链接()。干得好+1该版本的代码中存在一些错误,如果有人感兴趣,我很乐意提供当前版本。但请注意,该实现存在已知的限制(请参阅FIXMEs),我不能提供任何担保或承诺来支持该计划。也许最好使用一些像样的图像应用程序来完成这项工作,这(正如我在comp.lang.postscript中所说的)只是一个智力练习。但是,看到专业的代码,将自己的泥塑与之进行比较,总是很好的。:)@嗨,我的理解是,首先我们需要
$ tiff2pdf -h
LIBTIFF, Version 4.0.3
Copyright (c) 1988-1996 Sam Leffler
Copyright (c) 1991-1996 Silicon Graphics, Inc.
usage: tiff2pdf [options] input.tiff
options:
-o: output to file name
-j: compress with JPEG
-z: compress with Zip/Deflate
-q: compression quality
-n: no compressed data passthrough
-d: do not compress (decompress)
-i: invert colors
-u: set distance unit, 'i' for inch, 'm' for centimeter
-x: set x resolution default in dots per unit
-y: set y resolution default in dots per unit
-w: width in units
-l: length in units
-r: 'd' for resolution default, 'o' for resolution override
-p: paper size, eg "letter", "legal", "A4"
-F: make the tiff fill the PDF page
-f: set PDF "Fit Window" user preference
-e: date, overrides image or current date/time default, YYYYMMDDHHMMSS
-c: sets document creator, overrides image software default
-a: sets document author, overrides image artist default
-t: sets document title, overrides image document name default
-s: sets document subject, overrides image image description default
-k: sets document keywords
-b: set PDF "Interpolate" user preference
-h: usage
$ tiff2pdf -o output.pdf -p A4 -F test.tif