【问题标题】:How can I create a document with horizontal page orientation using google doc api如何使用 google doc api 创建具有水平页面方向的文档
【发布时间】:2020-02-20 16:09:12
【问题描述】:

如何使用 google doc api(如果可能,在 python 中)创建具有水平页面方向(横向)的文档

【问题讨论】:

标签: python google-docs-api


【解决方案1】:

这个很难。对于后代:

body = {
    'title': 'Doc1'
}

doc = service.documents() \
    .create(body=body).execute()

file_id = doc.get('documentId')
requests =[
    {'updateDocumentStyle':{
        "documentStyle":{
            'pageSize':{
                  "height": {
                        'magnitude': 8.27,
                        'unit': 'PT'
                    },
                  "width": {
                        'magnitude': 11.69,
                        'unit': 'PT'
                    }
                }},
        "fields": 'pageSize'
        
    }}]
result = service.documents().batchUpdate(
    documentId=file_id, body={'requests': requests}).execute()

【讨论】:

  • 使用这些值得到了一个奇怪的结果,3000 多页和 0 个左右边距,页面似乎有 1 毫米宽。使用值 width:842 height:595 对我有用,并在页面设置中显示“A4”和“Landscape”,这是我需要的。仅供参考,我浏览了文档,但完全错过了。非常感谢完整的示例!
  • 我认为有错字:'magnitude': 1.69 - 应该是 11.69
  • @noors 我现在没有能力检查它,但我认为你是对的
猜你喜欢
  • 2014-01-05
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2022-11-14
相关资源
最近更新 更多