如何通过COM类转换PPTX到PDF ?



我在用COM类将PPTX转换为PDF时遇到了一点问题。PowerPoint打开了,但不能用ExportAsFixedFormat函数转换为pdf,告诉我参数0是错误的类型。但是,我的路径是一个字符串,函数需要一个字符串,所以我很困惑吗?

你能帮我吗,我只是想转换PDF格式的PPTX:' ?

错误:

com_exception: Parameter 0: Le type ne correspond pas. in C:wamp64wwwTP1pt_legrandphpdemarrage_controle.php:13 Stack trace: #0 C:wamp64wwwTP1pt_legrandphpdemarrage_controle.php(13): variant->ExportAsFixedFormat2('C://wamp64//www...', 32) #1 C:wamp64wwwTP1pt_legrandphptexte.inc.php(24): include_once('C:\wamp64\www\T...') #2 C:wamp64wwwTP1pt_legrandindex.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;
}

也许,您可以尝试savea方法。老实说,这个类型不匹配的错误是相当不明显的。

$pp->ActivePresentation->SaveAs('THE_PATH/file.pdf', 32);

最新更新