public ConversionStatus BeginUncachedConversion(string fileName, int resolution)
{
try {
string converterExe = FindPdfConverterExe();
if (converterExe == null) {
conversionOutput = MiscText.PdfConverterNotFound;
status = ConversionStatus.Failure;
return status;
}
string arguments = String.Format(
"{2} \"{0}\" \"{1}\"",
pdfFileName, fileName, resolution);
stderrOutput = new StringBuilder();
ProcessStartInfo startInfo = new ProcessStartInfo(converterExe, arguments);
startInfo.CreateNoWindow = true;
startInfo.WindowStyle = ProcessWindowStyle.Hidden;
startInfo.RedirectStandardError = true;
startInfo.RedirectStandardOutput = true;
startInfo.UseShellExecute = false;
process = new Process();
process.StartInfo = startInfo;
process.EnableRaisingEvents = true;
process.ErrorDataReceived += ProcessDataReceived;
process.OutputDataReceived += ProcessDataReceived;
process.Exited += ProcessExited;
process.Start();
process.BeginOutputReadLine();
process.BeginErrorReadLine();
status = ConversionStatus.Working;
pngFileName = fileName;
return status;
}
catch (Exception e) {
status = ConversionStatus.Failure;
if (!string.IsNullOrWhiteSpace(pngFileName))
File.Delete(pngFileName);
conversionOutput = e.Message;
return status;
}
}