Reputation: 1794
I have to convert pcl file to pdf in my mvc4 project. I have found ghostPCL exe which does this job. but I am unable to find any reference how to use it in my mvc project. please help me regarding this.
Upvotes: 0
Views: 1662
Reputation: 111
I know this is an old post but wanted to share what i finally got to work as it took a while to figure out and since this is the posting that started me down the road to figuring things out, i thought i would provide details here so others who come across this posting like i did will have a good starting point. that said, here is what i got to work:
public static void Convert(string GhostscriptPath, String pclFile, String pdfFile)
{
var args = $"-dNOPAUSE -sOutputFile=\"{pdfFile}\" -sDEVICE=pdfwrite \"{pclFile}\"";
System.Diagnostics.Process process = new System.Diagnostics.Process();
process.StartInfo.FileName = GhostscriptPath;
process.StartInfo.Arguments = args;
process.StartInfo.CreateNoWindow = true;
process.StartInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Normal;
process.Start();
process.WaitForExit();
}
The GhostscriptPath string value is the full path to GhostPCL which can be downloaded from https://www.ghostscript.com/download/gpcldnld.html. Since I downloaded the 9.50 win32 version of GhostPCL to my C drive, the path I passed in as the GhostscriptPath was "C:\ghostpcl-9.50-win32\ghostpcl-9.50-win32\gpcl6win32.exe".
Upvotes: 1
Reputation:
Try this:
public void Convert(String pclFile, String pdfFile)
{
var command = String.Format(
"{0} -q -dNOPAUSE -sDEVICE=pdfwrite -sOutputFile={1} -f{2}",
GhostscriptPath, pdfFile, pclFile);
var process = System.Diagnostics.Process.Start(command);
}
where GhostscriptPath is, as the name describes, the path to Ghostscript on your PC.
Upvotes: 1