PDF直接打印使用adobereader
本文关键字:adobereader 打印 PDF | 更新日期: 2023-09-27 18:02:45
我尝试了这段代码用于PDF打印,但是当Adobe Reader打开时,给出了一个错误
文件和目录无法找到
代码运行良好,打开Adobe,但不加载文件打印。相反,它显示一个错误对话框。有人能告诉我我哪里错了吗?
private void PrintFormPdfData(byte[] formPdfData)
{`enter code here`
string tempFile;
tempFile = Path.GetTempFileName();
using (FileStream fs = new FileStream(tempFile, FileMode.Create))
{
fs.Write(formPdfData, 0, formPdfData.Length);
fs.Flush();
}
try
{
string gsArguments;
string gsLocation;
ProcessStartInfo gsProcessInfo;
Process gsProcess;
gsArguments = string.Format("-grey -noquery -printer '"HP LaserJet 5M'" '"{0}'"", tempFile);
gsLocation = @"C:'Program Files'Ghostgum'gsview'gsprint.exe";
gsProcessInfo = new ProcessStartInfo();
gsProcessInfo.WindowStyle = ProcessWindowStyle.Hidden;
gsProcessInfo.FileName = gsLocation;
gsProcessInfo.Arguments = gsArguments;
gsProcess = Process.Start(gsProcessInfo);
gsProcess.WaitForExit();
}
finally
{
File.Delete(tempFile);
}
}
fs.Close()缺失。所以gsprint不能打开文件。
注意:Flush before Close无效