我如何运行以下命令以使用 ghost 脚本在 Web 应用程序中将 pdf 转换为 jpeg。
我正在使用以下代码:
protected void Page_Load(object sender, EventArgs e)
{
string file = @"C:\pdf\p_o6GEE+.pdf";
string image = @"C:\image";
try
{
PdfToJpg(file, image);
}
catch (Exception ex)
{
throw ex;
}
}
private void PdfToJpg(string inputPDFFile, string outputImagesPath)
{
string ghostScriptPath = @"C:\Program Files\gs\gs9.09\bin\gswin32.exe";
String ars = "-dNOPAUSE -sDEVICE=jpeg -r300 -o" + outputImagesPath + "%d.jpg -sPAPERSIZE=a4 " + inputPDFFile;
Process proc = new Process();
proc.StartInfo.FileName = ghostScriptPath;
proc.StartInfo.Arguments = ars;
proc.StartInfo.CreateNoWindow = true;
proc.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
proc.Start();
proc.WaitForExit();
}
当我尝试运行此代码时,我的应用程序进入等待状态并且图像文件夹仍然为空。