Esempio n. 1
0
 private void ConvertToPdf(string tmpFile, string tmpDocx, string profile = null)
 {
     try
     {
         LibreOfficeUtils.Convert(tmpDocx, tmpFile, profile);
     }
     catch (Exception e)
     {
         throw ExitCode.PdfConversionFailed(tmpDocx, e).ToCommandException();
     }
 }
Esempio n. 2
0
 private void ConvertToPdfs(IEnumerable <string> docs, string outputDir, string profile = null)
 {
     try
     {
         LibreOfficeUtils.ConvertFiles(docs, outputDir, profile);
     }
     catch (Exception e)
     {
         throw ExitCode.PdfBatchConversionFailed(outputDir, e).ToCommandException();
     }
 }
Esempio n. 3
0
        private void EnsureLibreOffice()
        {
            if (!LibreOfficeUtils.IsLibreOfficeOnPath())
            {
                var(found, sofficePath) = LibreOfficeUtils.FindLibreOfficeBinary();

                if (found)
                {
                    var oldValue = Environment.GetEnvironmentVariable("PATH");
                    var newValue = oldValue + Path.PathSeparator + Path.GetDirectoryName(sofficePath);

                    Environment.SetEnvironmentVariable("PATH", newValue);
                }
                else
                {
                    throw ExitCode.LibreOfficeNotFound().ToCommandException();
                }
            }
            if (!LibreOfficeUtils.HasLibreOfficeProfile())
            {
                throw ExitCode.NoLibreOfficeProfile(LibreOfficeUtils.ExpectedProfileDir).ToCommandException();
            }
        }