以 pdf 格式导出演示文稿
Export presentation on pdf format
我想使用 g-slide api 导出 google 幻灯片演示文稿 en pdf 格式 api,我使用了这个 Google api 函数:
$fileId = '1ZdR3L3qP4Bkq8noWLJHSr_iBau0DNT4Kli4SxNc2YEo';
$response = $driveService->files->export($fileId, 'application/pdf', array('alt' => 'media' ));
$content = $response->getBody()->getContents();
当我执行 print_r($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_dir['path']
是我的文件夹项目路径。
我想使用 g-slide api 导出 google 幻灯片演示文稿 en pdf 格式 api,我使用了这个 Google api 函数:
$fileId = '1ZdR3L3qP4Bkq8noWLJHSr_iBau0DNT4Kli4SxNc2YEo';
$response = $driveService->files->export($fileId, 'application/pdf', array('alt' => 'media' ));
$content = $response->getBody()->getContents();
当我执行 print_r($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_dir['path']
是我的文件夹项目路径。