我在使用 COM 类将 PPTX 转换为 PDF 时遇到了一些问题。 PowerPoint 打开但无法使用 ExportAsFixedFormat 函数转换为 pdf,告诉我参数 0 的类型错误。但是,我的路径是一个字符串,函数需要一个字符串,所以我很困惑?
你能帮我吗,我只想将 PPTX 转换为 PDF :'( ?
错误:
com_exception: Parameter 0: Le type ne correspond pas. in C:\wamp64\www\TP1\pt_legrand\php\demarrage_controle.php:13 Stack trace: #0 C:\wamp64\www\TP1\pt_legrand\php\demarrage_controle.php(13): variant->ExportAsFixedFormat2('C://wamp64//www...', 32) #1 C:\wamp64\www\TP1\pt_legrand\php\texte.inc.php(24): include_once('C:\\wamp64\\www\\T...') #2 C:\wamp64\www\TP1\pt_legrand\index.php(8): require_once('C:\\wamp64\\www\\T...') #3 {main}
我的代码:
try{
$pp = new COM("Powerpoint.Application") or die ("Could not initialise Object.");
$pp->Visible = true;
// open the pp 2007-2013 document
$pp->Presentations->Open('C://wamp64//www//TP1//pt_legrand//php//test.pptx');
// convert pp 2007-2013 to PDF
$filePath = 'C://wamp64//www//TP1//pt_legrand//php';
$pp->ActivePresentation->ExportAsFixedFormat2(
$filePath,
2
);
$pp->Quit(false);
// clean up
unset($pp);
}catch(Exception $e){
echo $e;
}
答案 0 :(得分:0)
也许,您可以尝试 SaveAs 方法。老实说,这种类型不匹配错误并不明显。
$pp->ActivePresentation->SaveAs('THE_PATH/file.pdf', 32);