internal static bool wordAsConverter(string rtf, string pdf, bool verb = true, bool clean = true)
{
$"\t..try convert to pdf...".print();
var res = false;
var app = new Application();
try
{
var doc = app.Documents.Open(rtf);
doc.ExportAsFixedFormat(pdf, WdExportFormat.wdExportFormatPDF);
doc.Close(false);
res = true;
var fn = Path.GetFileName(rtf);
if (verb) $"\t{fn} converted to pdf".print();
if (clean)
{
File.Delete(rtf);
if (verb) $"\t{fn} deleted".print();
}
}
catch (Exception e) { e.Message.print(); }
finally { app.Quit(false); }
return res;
}
// привычка, для уменьшения многословности кода
internal static void print(this string s) => Console.WriteLine(s);