using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace IRaCIS.Core.Application.Helper
{
    public class FileConvertHelper
    {


        static public void ConvertWordToPdf(string inputWordFilePath, string outputPdfDir)
        {
            // 设置 libreoffice 命令行参数
            string arguments = $"--headless --invisible --convert-to pdf \"{inputWordFilePath}\" --outdir \"{outputPdfDir}\"";

            // 启动 libreoffice 进程
            using (Process process = new Process())
            {
                process.StartInfo.FileName = "libreoffice";
                process.StartInfo.Arguments = arguments;
                process.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
                process.StartInfo.RedirectStandardOutput = true;
                process.StartInfo.RedirectStandardError = true;
                process.StartInfo.UseShellExecute = false;
                process.StartInfo.CreateNoWindow = true;

                process.Start();

                // 等待进程结束
                process.WaitForExit();
            }
        }


    }
}