通过Drive API创建具有特定页面设置(边距,方向)的文档 [英] Create Docs through the Drive API with specific page setups (margins, orientation)

查看:115
本文介绍了通过Drive API创建具有特定页面设置(边距,方向)的文档的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的应用程式已可透过云端硬碟API建立「Google文件」,并且可以选择标题,资料和元数据。但我一直在查看文档,似乎没有办法设置文档的其他属性,例如创建的文档的边距和方向(纵向或横向)。有没有办法做到这一点?



在文档中找不到答案之后,我唯一能想到的就是使用我的Google帐户登录,创建的文档,点击页面设置,然后选择风景,最后选择设为默认。我认为通过将其设置为我的Google帐户中的默认设置,可能会发生创建的所有文档都可能创建为横向广告。但它没有奏效。但是,可能的原因是,实际创建文档的帐户是服务帐户,而不是我的常规Google帐户。我猜这两个帐户在被链接的时候并不是一回事,因此一个帐户的默认值不适用于另一个帐户。有什么方法可以将肖像设置为使用我的服务帐户创建的文档的默认方向?如果不是,那么解决方案是停止使用我的服务帐户创建文档,并开始使用我的常规Google帐户创建文档,以便我应用于他们的默认设置也适用于新创建的文档?

$ b $



驱动API不支持与文档相关的功能,以便检索/设置有关文档的元数据。 服务帐户是个人Google帐户,与您自己的用户帐户无关。另一方面,您的默认设置将仅适用于您。您无法以编程方式设置其他用户的默认设置。


My app is already able to create Google Docs through the Drive API, and when doing so I can choose the title, data, and metadata. But I've been looking at the documentation and it seems there is no way to set some other properties of the Docs, such as the margins and the orientation (portrait or landscape) of the Docs being created. Is there a way to do so?

After not finding an answer in the documentation, the only thing I could think of was logging in with my Google Account, going to one of the created Docs, click on "Page setup", then select "Landscape", and finally "Set as default". I thought that by setting it as the default in my Google Account, it may happen that all the Docs created with it may be created as Landscapes. But it didn't work. A possible reason, however, is that the account actually creating the documents is a Service Account, not my regular Google Account. I guess both accounts, while being linked, are not the same thing, so the defaults of one don't apply to the other. Is there some way to set "Portrait" as the default orientation for the Docs created with my Service Account? If not, would the solution be to stop creating the Docs with my Service Account, and start creating them with my regular Google Account, so that the defaults I apply to them apply too to the newly created Docs?

解决方案

Drive API doesn't support Docs related features for you to retrieve/set metadata about the documents.

Service accounts are individual Google accounts and no way related with your own user account. On the other hand, your default settings will only apply to you. You cant programatically set other user's defaults.

这篇关于通过Drive API创建具有特定页面设置(边距,方向)的文档的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆