Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/252.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 导出pdf格式的演示文稿_Php_Pdf_Google Drive Api_Google Slides Api - Fatal编程技术网

Php 导出pdf格式的演示文稿

Php 导出pdf格式的演示文稿,php,pdf,google-drive-api,google-slides-api,Php,Pdf,Google Drive Api,Google Slides Api,我想使用g-slide api导出google幻灯片演示文稿en pdf格式,我使用了以下google api函数: $fileId = '1ZdR3L3qP4Bkq8noWLJHSr_iBau0DNT4Kli4SxNc2YEo'; $response = $driveService->files->export($fileId, 'application/pdf', array('alt' => 'media' )); $content = $response->get

我想使用g-slide api导出google幻灯片演示文稿en pdf格式,我使用了以下google api函数:

$fileId = '1ZdR3L3qP4Bkq8noWLJHSr_iBau0DNT4Kli4SxNc2YEo';
$response = $driveService->files->export($fileId, 'application/pdf', array('alt' => 'media' ));
$content = $response->getBody()->getContents();

当我打印($content)时,我可以看到pdf代码。但是如何在pdf文件中显示
$content
,我可以将其保存在本地计算机上?

我解决了这样的问题:

$driveService = new \Google_Service_Drive($client);
$response = $driveService->files->export($presentation_id, 'application/pdf', array('alt' => 'media' ));
$content = $response->getBody()->getContents();
$filename = str_replace(" ", "-", 'pdf_name.pdf');

file_put_contents($upload_dir['path'].'/'.$filename, $content);

$upload\u dir['path']
是我的文件夹项目路径。

我只想确认一下。您想将google幻灯片文件保存为PDF文件吗?是的,就是这样,