QPDF could convert a pdf to linearized pdf(web fast view property). I could use the command line: qpdf --linearize input.pdf output.pdf to transfer a pdf to a linearized pdf.
How could I use it on asp.net program?
My code is like that
private void LaunchCommandLineApp()
{
// For the example
string ex4 = @"C:\Program Files\qpdf-7.0.b1\bin\qpdf.exe";
// Use ProcessStartInfo class
ProcessStartInfo startInfo = new ProcessStartInfo();
startInfo.CreateNoWindow = false;
startInfo.UseShellExecute = false;
startInfo.RedirectStandardInput = true;
startInfo.RedirectStandardError = true;
startInfo.RedirectStandardOutput = true;
startInfo.FileName = ex4;
startInfo.WindowStyle = ProcessWindowStyle.Hidden;
startInfo.Arguments = " --linearize input.pdf output.pdf";
try
{
// 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();
Console.WriteLine(op);
}
}
}
catch (Exception ex)
{
// Log error.
}
}
Is there any other solution to use Qpdf in asp.net? Thanks much!
Finally, I use the qpdf.exe to make it work as the following code.
Also, I added the "write" permission to asp.net user role on my output folder as well. Hope it helps.