如何在页脚中插入PAGE_NUMBER和PAGE_COUNT

问题描述 投票:3回答:2

我正在寻找页脚中段落和元素段落的示例。我试过了,但是我只能在页脚中插入文本:

$requests = array (new \Google_Service_Docs_Request(array(
    'insertText' => array(
        'location' => array(
            'segmentId' => $segmentId,
                'index' => 0
            ),
            "text" => 'My Text'
        )
)),

我试图实现这样的新页脚:

$footers = array(
        new \Google_Service_Docs_Footer(array(
            'footerId' => $segmentId,
            'content' => [
                'paragraph' => [
                    'element' => [
                        'textRun' => [
                            'content' => 'My Text - '
                        ]
                    ]
                ]
            ]
        )),
        new \Google_Service_Docs_Footer(array(
            'footerId' => $segmentId,
            'content' => [
                  'paragraph' => [
                      'element' => [
                          'AutoText' => [
                              'type' => 'PAGE_NUMBER'
                          ]
                      ]
                  ]
            ]
        )),
        new \Google_Service_Docs_Footer(array(
            'footerId' => $segmentId,
            'content' => [
                'paragraph' => [
                    'element' => [
                        'AutoText' => [
                            'type' => 'PAGE_COUNT'
                        ]
                    ]
                ]
            ]
        ))
    );
    $document->setFooters($footers);

我们可以管理页脚的段落吗?

php google-docs-api
2个回答
2
投票

我认为您不能通过API插入AutoText。没有可用于此的有效request from batchUpdate(通过InsertTextRequest插入的文本必须是字符串)。因此,只能通过UI设置PAGE_NUMBERPAGE_COUNT:如果使用的是API,则只能检索它们。


1
投票

正在发布https://issuetracker.google.com/issues/149275293收到反馈后,我会与您保持联系

© www.soinside.com 2019 - 2024. All rights reserved.