try { $excel = new \COM('Excel.Application') or die ("Error: Could not windows excel Object."); $excel->Visible = 0; $excel->Workbooks->Open($inpath) or die("ERROR: Unable to open $basename");
// 存在就删除 if (file_exists($outpath)) { unlink($outpath); }
// 文件路径 $inpath = 'D:/abc.docx'; // 要转换的 WORD 文件路径 $outpath = 'D:/abc.pdf'; // 转换后的 PDF 路径
try { $word = new \COM('Word.Application') or die ("Error: Could not windows excel Object."); $word->Visible = 0; $word->DisplayAlerts = 0; $word->Documents->Open($inpath) or die("ERROR: Unable to open $basename");
//存在就删除 if (file_exists($outpath)) { unlink($outpath); }