Php 使用api google doc在标题中居中显示图像
我试图在标题中插入图像。没关系。 现在我想把照片居中,但我被卡住了Php 使用api google doc在标题中居中显示图像,php,google-docs,Php,Google Docs,我试图在标题中插入图像。没关系。 现在我想把照片居中,但我被卡住了 $requests[] = new \Google_Service_Docs_Request(array( 'insertInlineImage' => array( 'uri' => 'https://myPicture.png', 'location' => array( 'segmentId' => $d
$requests[] = new \Google_Service_Docs_Request(array(
'insertInlineImage' => array(
'uri' => 'https://myPicture.png',
'location' => array(
'segmentId' => $document->getDocumentStyle()->getDefaultHeaderId(),
'index' => 0
),
),
));
- 您希望在Google文档的标题中心插入一个内联图像
- 您希望通过使用带有php的google api php客户端来实现这一点
- 您已经能够使用GoogleDocsAPI获取和放置Google文档的值
- 为了将图像放在中间,请将UpdateParagraphStyleRequest添加到batchUpdate的请求正文中,因为InsertInlineImageRequest没有对齐的特性
- 当无法使用
时,请将标题ID设置为字符串值,如$document->getDocumentStyle()->getDefaultHeaderId()
kix.###
- 这是一个简单的修改。因此,请将此反映到您的实际脚本中
- 您希望在Google文档的标题中心插入一个内联图像
- 您希望通过使用带有php的google api php客户端来实现这一点
- 您已经能够使用GoogleDocsAPI获取和放置Google文档的值
- 为了将图像放在中间,请将UpdateParagraphStyleRequest添加到batchUpdate的请求正文中,因为InsertInlineImageRequest没有对齐的特性
- 当无法使用
时,请将标题ID设置为字符串值,如$document->getDocumentStyle()->getDefaultHeaderId()
kix.###
- 这是一个简单的修改。因此,请将此反映到您的实际脚本中
如果我误解了你的问题,而这不是你想要的方向,我向你道歉。这正是我想要做的。而且效果很好。非常感谢,欢迎光临。谢谢你让我知道。我很高兴你的问题解决了。如果您的问题已解决,请按“接受”按钮。与您有相同问题的其他人也可以将您的问题作为可以解决的问题。我认为你的问题和解决方案对他们会有帮助。如果你找不到按钮,尽管告诉我。这正是我想做的。而且效果很好。非常感谢,欢迎光临。谢谢你让我知道。我很高兴你的问题解决了。如果您的问题已解决,请按“接受”按钮。与您有相同问题的其他人也可以将您的问题作为可以解决的问题。我认为你的问题和解决方案对他们会有帮助。如果你找不到按钮,尽管告诉我。
$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);