1

我想使用 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();

当我这样做时,print_r($content)我可以看到 pdf 代码。但是我如何显示$contentpdf文件,我可以保存在本地机器上吗?

4

1 回答 1

2

我这样解决问题:

$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_dir['path']对我来说是一个文件夹项目路径。

于 2017-03-01T15:18:44.073 回答