okk*_*kki 5 php google-api google-drive-api google-api-php-client
我正在使用Google Drive v3并尝试将 Google 电子表格文件导出为 PDF。几乎一切都按预期进行。
例外:
生成的 PDF 始终采用LETTER和PORTRAIT格式,但我需要DIN A4和横向格式的 pdf 。我无法找到任何设置/参数来提交到 v3 以生成其他格式的 PDF。
我找到了适用于 Google Drive v2 的解决方案,但没有找到适用于 Google Drive v3 的解决方案。
将格式或肖像作为可选参数传递会导致错误:-(
/**
* Downloads a Google file in a specified mime type.
*
* @param string $googleDriveFileId id of the drive file which should be downloaded
* @param string $mimeType mime type
* @param string[] $optParams
*
* @return Response
*
* @link https://developers.google.com/drive/api/v3/reference/files/export
* @link https://developers.google.com/drive/api/v3/ref-export-formats
*/
public function download(string $googleDriveFileId, string $mimeType, array $optParams= []): Response
{
/** @var Response $resonse */
return $this->googleServiceProvider->getGoogleServiceDrive()->files->export(
$googleDriveFileId,
$mimeType,
$optParams
);
}
Run Code Online (Sandbox Code Playgroud)
[...]
"name": "google/apiclient",
"version": "v2.11.0",
[...]
Run Code Online (Sandbox Code Playgroud)
小智 0
您可以使用链接下载该文件。
https://docs.google.com/spreadsheets/d/[YOUR-ID]/export?format=pdf&portrait=false&size=A4
| 归档时间: |
|
| 查看次数: |
3102 次 |
| 最近记录: |