ส่งออกการนำเสนอในรูปแบบ pdf

ฉันต้องการส่งออกการนำเสนอสไลด์ของ Google ในรูปแบบ pdf โดยใช้ g-slide api ฉันใช้ฟังก์ชัน Google api นี้:

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

เมื่อฉันทำ print_r($content) ฉันจะเห็นรหัส pdf แต่ฉันจะแสดง $content ในไฟล์ pdf ได้อย่างไร ฉันสามารถบันทึกไว้ในเครื่องท้องถิ่นได้หรือไม่


person Malki Mohamed    schedule 28.02.2017    source แหล่งที่มา
comment
ฉันแค่อยากจะยืนยัน คุณต้องการบันทึกไฟล์ Google Slide บนคอมพิวเตอร์ของคุณเป็นไฟล์ PDF หรือไม่?   -  person noogui    schedule 01.03.2017
comment
ใช่ แค่นั้นแหละ   -  person Malki Mohamed    schedule 01.03.2017


คำตอบ (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'] เป็นเส้นทางโปรเจ็กต์โฟลเดอร์สำหรับฉัน

person Malki Mohamed    schedule 01.03.2017