내가 업로드하고 HTML 파일을 업데이트하고 문자로 설정 용지 크기의 문서를 생성생성 Google 드라이브에 문서 및
include_once ROOT.'/google-api-php-client/vendor/autoload.php';
$client = new Google_Client();
$credentialsFile = ROOT.'/google-api-php-client/service_account.json';
if (!file_exists($credentialsFile)) {
throw new RuntimeException('Service account credentials Not Found!');
}
$client->setAuthConfig($credentialsFile);
$client->setScopes(Google_Service_Drive::DRIVE);
$service = new Google_Service_Drive($client);
/**
* Проверка существования папки для документов
*/
$optParams = array(
'q' => "name='Документы'"
);
$results = $service->files->listFiles($optParams);
if (count($results->getFiles()) == 0) {
exit('Нет папки для документов');
} else {
foreach ($results->getFiles() as $file) {
$papka_doc = $file->getId();
}
}
/**
* Обращение к шаблону
*/
$optParams = array(
'q' => "name='{$tpl_name}' "
);
$results = $service->files->listFiles($optParams);
if (count($results->getFiles()) == 0) {
exit('Нет шаблона');
} else {
foreach ($results->getFiles() as $file) {
$sh_id = $file->getId();
}
}
/**
* Получение контента из шаблона
*/
$content = $service->files->export($sh_id, 'text/html', array(
'alt' => 'media'));
$dd =$content->getBody();
$chto = array_keys ($replace);
$chto= $this->translit($chto);
$nachto =array_values ($replace);
$nachto= $this->translit($nachto);
$dd = str_replace($chto, $nachto, $dd);
/**
* Создание основы для документа
*/
$fileId = $sh_id;
$doc_name = $tpl_name.'_'.date('dmY-Hi');
$fileMetadata = new Google_Service_Drive_DriveFile(array(
'name' => $doc_name,
'parents' => array($papka_doc)));
$file = $service->files->copy($fileId, $fileMetadata, array(
'fields' => 'id'));
$new_file_id = $file->id;
/**
* Вставка контента в новый документ
*/
$fileMetadata = array(
'data' => $dd);
$filenew = new Google_Service_Drive_DriveFile();
$file = $service->files->update($new_file_id, $filenew, $fileMetadata);
기본 Google 문서로 변환하기 위해 PHP 라이브러리를 사용의 용지 크기를 변경 . 내 계정의 경우 기본값은 A4이며 새로 만든 문서를이 형식으로 만들려고합니다. 누구나 업로드 된 문서의 용지 크기를 설정하는 방법을 알고 있습니까?
피씨 : this 실을 봤지만 방법이 나타날 수 있습니까?
문서를 검색했지만 불행히도 관련 예제를 찾지 못했습니다. [thread] (http://stackoverflow.com/questions/24183561/uploading-a-document-to-google-drive-and-setting-its-paper-size)에 명시된 바와 같이 아직 지원되지 않습니다. 그러나 이에 대한 [기능 요청] (https://productforums.google.com/forum/#!topic/drive/TESSj1GH1Xw)을 제출할 수 있습니다. – abielita