I am trying to add headers and texts for my file created in GoogleDrive API.
I have array with summary which I want to add to my file. But on the left side (headers synapsis) I want to have only my headers from array. When I click on header I want my file to scroll to my title. My problem is, no in my headers on my felt side I also have description. How Can i make only headers (array keys) on left side and headers with text in my file content?
$summary = [
'Title' => "test title",
'Length' => "3000",
'Links' => "http://localhost:4200/#/clients/1/test1, http://localhost:4200/#/clients/1/test2",
'Keywords' => "mouse, keyboard",
'Description' => "detail description, etc."
];
$this->googleDriveClient->addTextSummary($externalId, $summary);
code of addTextSummary:
public function addTextSummary(string $documentId, array $summary)
{
$requests = [];
$headersLength = 1;
foreach ($summary as $header => $text) {
$requests[] = new Google_Service_Docs_Request([
'insertText' => [
'endOfSegmentLocation' => [],
'text' => $header . "n"
]
]);
$requests[] = new Google_Service_Docs_Request([
'insertText' => [
'endOfSegmentLocation' => [],
'text' => $text . "nn"
]
]);
$headersLength += strlen($header) + strlen($text);
}
$requests[] = new Google_Service_Docs_Request([
'updateParagraphStyle' => [
'range' => [
'startIndex' => 1,
'endIndex' => $headersLength + 1
],
'paragraphStyle' => [
'namedStyleType' => 'HEADING_1'
],
'fields' => 'namedStyleType'
]
]);
$batchUpdateRequest = new Google_Service_Docs_BatchUpdateDocumentRequest([
'requests' => $requests
]);
$this->docsService->documents->batchUpdate($documentId, $batchUpdateRequest);
}
in result I have file like this:
My goal is to have file content like in my attachment, but I want to remove text from left side, and have only titles there (only array keys like Title, Length, etc.). I dont want to have array values (like “test title”, “mouse, keyboard”) on my left side of file. How can I do this?