1 回答

TA貢獻1824條經(jīng)驗 獲得超8個贊
您希望在 Google 文檔中的頁眉中心插入一個內(nèi)聯(lián)圖片。
你想用谷歌-阿提-php-客戶端和PHP來實現(xiàn)這一點。
您已經(jīng)能夠使用谷歌文檔API獲取和輸入谷歌文檔的值。
如果我的理解是正確的,這個答案怎么樣?請把這看作是幾個可能的答案之一。
修改點:
為了將圖像放在中心位置,請將更新參數(shù)樣式請求添加到批處理更新的請求正文中,因為插入內(nèi)聯(lián)圖像請求沒有 。
alignment
修改后的腳本:
$documentId = '###'; // Please set the Document ID.
$segmentId = $document->getDocumentStyle()->getDefaultHeaderId();
$service = new Google_Service_Docs($client);
$requests = [
new Google_Service_Docs_Request([
'insertInlineImage' => [
'location' => ['index' => 0, 'segmentId' => $segmentId],
'uri' => 'https://icir.int.demedicis.fr/img/logo/veolia.png'
]
]),
new Google_Service_Docs_Request([
'updateParagraphStyle' => [
'range' => ['startIndex' => 0, 'endIndex' => 1, 'segmentId' => $segmentId],
'paragraphStyle' => ['alignment' => 'CENTER'],
'fields' => 'alignment'
]
])
];
$batchUpdateRequest = new Google_Service_Docs_BatchUpdateDocumentRequest(['requests' => $requests]);
$result = $service->documents->batchUpdate($documentId, $batchUpdateRequest);
注意:
當無法使用時,請將標頭ID設置為字符串值。
$document->getDocumentStyle()->getDefaultHeaderId()
kix.###
這是一個簡單的修改。因此,請將此內(nèi)容反映到您的實際腳本中。
引用:
如果我誤解了你的問題,這不是你想要的方向,我很抱歉。
- 1 回答
- 0 關(guān)注
- 114 瀏覽
添加回答
舉報