如何在c#中使用ghostPCL将pcl文件转换为pdf

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

我必须在我的mvc4项目中将pcl文件转换为pdf。我发现执行此工作的ghostPCL exe。但是我找不到在我的mvc项目中如何使用它的任何参考。请对此提供帮助。

c# asp.net-mvc ghostscript
2个回答
1
投票

尝试一下:

public void Convert(String pclFile, String pdfFile)
{
    var command = String.Format(
        "{0} -q -dNOPAUSE -sDEVICE=pdfwrite -sOutputFile={1} -f{2}",
        GhostscriptPath, pdfFile, pclFile);
    var process = System.Diagnostics.Process.Start(command);
}

其中GhostscriptPath如其名称所描述,是PC上Ghostscript的路径。


0
投票

我知道这是一个老帖子,但是我想分享一下我最终要花的时间,因为花了一段时间才弄清楚,由于这是我开始着手解决问题的帖子,我想我会提供详细信息在这里,这样像我一样遇到此帖子的其他人将有一个很好的起点。就是说,这就是我要工作的地方:

public static void Convert(string GhostscriptPath, String pclFile, String pdfFile)

{

var args = $"-dNOPAUSE -sOutputFile=\"{pdfFile}\" -sDEVICE=pdfwrite \"{pclFile}\"";


System.Diagnostics.Process process = new System.Diagnostics.Process();
process.StartInfo.FileName = GhostscriptPath;
process.StartInfo.Arguments = args;
process.StartInfo.CreateNoWindow = true;
process.StartInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Normal;
process.Start();
process.WaitForExit();

}

GhostscriptPath字符串值是GhostPCL的完整路径,可以从https://www.ghostscript.com/download/gpcldnld.html下载。因为我将9.50 win32版本的GhostPCL下载到了C驱动器,所以我作为GhostscriptPath传递的路径是“ C:\ ghostpcl-9.50-win32 \ ghostpcl-9.50-win32 \ gpcl6win32.exe”。

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