Q: How do I use the DocPub CLI executable on an
ASP.NET server?
==========================================================
A: You can run DocPub on an
ASP.NET server just like any other executable.
This C# code snippet can be used in a controller:
System.Diagnostics.Process process1 = new System.Diagnostics.Process();
process1.StartInfo.FileName = @"C:\Users\PDFTron\Documents\visual studio 2010\Projects\MvcApplication2\MvcApplication2\bin\docpub32.exe"; //path to docpub executable
process1.StartInfo.WorkingDirectory = @"C:\Users\PDFTron\Documents\visual studio 2010\Projects\MvcApplication2\MvcApplication2\bin\"; //directory of pdf file
process1.StartInfo.Arguments = "-f xod document.pdf"; //docpub arguments
process1.StartInfo.UseShellExecute = false;
process1.StartInfo.RedirectStandardOutput = true;
process1.Start();
//wait for the process to finish
process1.WaitForExit();
//print out the CLI output for debugging
StreamReader myStreamReader = process1.StandardOutput;
String stdOut = myStreamReader.ReadToEnd();
System.Diagnostics.Debug.WriteLine(stdOut);
process1.Close();
If you need more PDF features (manipulation, flattening, optimizing etc.), PDFNet SDK for .NET is also available for
ASP.NET.