GhostScript的v9.10 64位版本转换列表使用Ghostscript
我想借此JPG文件的列表,并把它们变成每张图片都有自己的页面一个PDF文件为PDF。
我试图按照这里使用的方法: Using Ghostscript to convert JPEG to PDF但我得到错误。
这里是我的命令:
C:\Temp>gswin64c -sDEVICE=pdfwrite -o cafb0173-f4be-47a8-a39e-f479ca0a4d09.pdf viewjpeg.ps -c 5c520934-461a-44f3-9f00-9fdc9fe666c1.jpg
这里是我所得到的:
GPL Ghostscript 9.10 (2013-08-30)
Copyright (C) 2013 Artifex Software, Inc. All rights reserved.
This software comes with NO WARRANTY: see the file PUBLIC for details.
Error: /undefined in 5c520934-461a-44f3-9f00-9fdc9fe666c1.jpg
Operand stack:
Execution stack:
%interp_exit .runexec2 --nostringval-- --nostringval-- --nostringval-- 2 %stopped_pus
h --nostringval-- --nostringval-- --nostringval-- false 1 %stopped_push .runexec2 --
nostringval-- --nostringval-- --nostringval-- 2 %stopped_push --nostringval--
Dictionary stack:
--dict:1179/1684(ro)(G)-- --dict:0/20(G)-- --dict:80/200(L)--
Current allocation mode is local
Last OS error: No such file or directory
GPL Ghostscript 9.10: Unrecoverable error, exit code 1
我使用的完整路径viewjpeg.ps尝试过了,我试图把viewJPEG showpage
在最终,那也没有帮助。
当我运行此C#代码然而,:
try
{
var guid = System.Guid.NewGuid().ToString();
Process p = new Process();
p.StartInfo.WorkingDirectory = @"C:\Temp";
p.StartInfo.FileName = Program.ghostScriptLocation;
p.StartInfo.Arguments = " -sDEVICE=pdfwrite -o " + guid + ".pdf " + "\""+Program.viewJPEGLoc+"\"" +" -c " + String.Join(" ", pictures.ToArray());
p.StartInfo.UseShellExecute = false;
p.StartInfo.RedirectStandardOutput = true;
p.Start();
string outp = p.StandardOutput.ReadToEnd();
p.WaitForExit();
}
catch (Exception e)
{
Console.WriteLine(e.Message);
}
得到了一个空白的PDF文件,以及一个错误,说“不可恢复的错误,退出代码1”
我的问题标题提到了一个文件列表。我如何做到这一点与多个文件? – Houseman 2014-10-13 16:54:28
那么,你可以编写一个脚本来为你想要处理的每个文件调用一次Ghopstscript。或者,您可以修改viewjpeg.ps程序并为其提供多个文件。例如,您可以提供一个字符串数组,并让viewjpeg.ps程序在数组中循环,而不是使用单个文件名的字符串。 – KenS 2014-10-13 17:55:53
因此,使用stockjpeg.ps文件,将多个jpg文件封装到一个PDF中是不可能的? – Houseman 2014-10-13 18:12:27