【问题标题】:How to set headers and footers in a new document with google-docs-api and Java如何使用 google-docs-api 和 Java 在新文档中设置页眉和页脚
【发布时间】:2019-05-02 14:47:49
【问题描述】:

我需要使用 google-docs-api 复制 word 文档,但我不知道如何在新文档中插入页眉和页脚。好像没有这个要求。 有什么建议吗?

【问题讨论】:

  • 我今天使用google-docs-api 实现了将标题插入新文档。请注意,这是 2019 年 10 月 25 日发布的最新版本

标签: java google-docs-api


【解决方案1】:

据我了解,您可以使用方法documents.create 使用请求中给出的标题创建一个空白文档。

HTTP 请求

POST https://docs.googleapis.com/v1/documents

请求正文

{
  "documentId": string,
  "title": string,
  "body": {
    object(Body)
  },
  "headers": {
    string: {
      object(Header)
    },
    ...
  },
  "footers": {
    string: {
      object(Footer)
    },
    ...
  },
  "footnotes": {
    string: {
      object(Footnote)
    },
    ...
  },
  "documentStyle": {
    object(DocumentStyle)
  },
  "suggestedDocumentStyleChanges": {
    string: {
      object(SuggestedDocumentStyle)
    },
    ...
  },
  "namedStyles": {
    object(NamedStyles)
  },
  "suggestedNamedStylesChanges": {
    string: {
      object(SuggestedNamedStyles)
    },
    ...
  },
  "lists": {
    string: {
      object(List)
    },
    ...
  },
  "namedRanges": {
    string: {
      object(NamedRanges)
    },
    ...
  },
  "revisionId": string,
  "suggestionsViewMode": enum(SuggestionsViewMode),
  "inlineObjects": {
    string: {
      object(InlineObject)
    },
    ...
  },
  "positionedObjects": {
    string: {
      object(PositionedObject)
    },
    ...
  }
}

headersfooters 字段代表文档中的页眉和页脚,分别以页眉 ID 和页脚 ID 为键。

【讨论】:

  • 使用documents.create请求后,生成的Document资源实际上并不包含headers字段来检索headerId
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2012-03-11
  • 2023-03-29
  • 1970-01-01
  • 2018-05-14
  • 1970-01-01
相关资源
最近更新 更多