QPDF可以将pdf转换为线性化pdf(web快速查看属性)。我可以使用命令行: qpdf - 使输入.pdf output.pdf线性化以将pdf传输到线性化的pdf。
我如何在asp.net程序中使用它?
我的代码就是那样
extra_fields
在asp.net中有没有其他解决方案可以使用Qpdf?非常感谢!
答案 0 :(得分:0)
最后,我使用qpdf.exe使其工作如下代码。
private void RunQpdfExe(string output)
{
string QPDFPath = @"C:\Program Files\qpdf-5.1.2\bin\";
string newfile = ExportFilePath + "Lin.pdf";
try
{
// Use ProcessStartInfo class
ProcessStartInfo startInfo = new ProcessStartInfo();
startInfo.CreateNoWindow = false;
startInfo.UseShellExecute = false;
startInfo.RedirectStandardInput = true;
startInfo.RedirectStandardError = true;
startInfo.RedirectStandardOutput = true;
startInfo.FileName = QPDFPath + "qpdf.exe";
startInfo.Verb = "runas";
startInfo.WindowStyle = ProcessWindowStyle.Hidden;
//startInfo.Arguments = " --check " + output;
startInfo.WorkingDirectory = Path.GetDirectoryName(QPDFPath);
startInfo.Arguments = " --linearize " + output + " " + newfile;
// Start the process with the info we specified.
// Call WaitForExit and then the using statement will close.
using (Process exeProcess = Process.Start(startInfo))
{
if (exeProcess != null)
{
string op = exeProcess.StandardOutput.ReadToEnd();
exeProcess.WaitForExit();
}
}
//Rename the output file back
File.Delete(output);
File.Copy(newfile, output);
File.Delete(newfile);
}
catch (Exception)
{
// Log error.
}
}
另外,我添加了"写"我的输出文件夹上的asp.net用户角色的权限。希望能帮助到你。