我想使用g-slide api导出google slide presentation pdf格式,我使用了这个Google api函数:
toList :: Tree a -> [a]
toList (Node (Leaf a) (Leaf b)) = [a] ++ [b]
toList (Node (Leaf a) (Node x y)) = [a] ++ (toList (Node x y))
toList (Node (Node x y) (Leaf b)) = (toList (Node x y)) ++ [b]
当我$fileId = '1ZdR3L3qP4Bkq8noWLJHSr_iBau0DNT4Kli4SxNc2YEo';
$response = $driveService->files->export($fileId, 'application/pdf', array('alt' => 'media' ));
$content = $response->getBody()->getContents();
时,我可以看到pdf代码。但是如何在pdf文件上显示print_r($content)
,我可以在本地机器上保存?
答案 0 :(得分:1)
我解决了这个问题:
$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']
是我的文件夹项目路径。