7

I'm creating a Google Doc to HTML converter, I want to use the Doc Api and not export it as HTML using the Drive Api :

$service = new Google_Service_Docs($client);
$request = $service->documents->get($docId);

$elements = $request->getBody()->getContent();

$elements is an array of Google_Service_Docs_StructuralElement

Looping through paragraph > elements, if there is an inline object, the inlineObjectElement property is set with a Google_Service_Docs_InlineObjectElement

Question is : how to get the content of an Google_Service_Docs_InlineObjectElement to save it as a file ? All we have in this object is an inlineObjectId...

Jérome B
  • 71
  • 1

1 Answers1

1

I was able to find a solution for this on this blog post.

Basically, all inline elements are located at:

$inlineObjects = $request->getInlineObjects();

Btw. I recommend renaming "$request" to "$document"

Now, with the inlineObjectId you can get the particular object you want - and there, you get a contentUri which contains the binary content.

Here, a screenshot of $inlineObjects contents, which is an assoc array. The key is the inlineObjectId:

Screenshot of the Google_Service_Docs_InlineObject in var dumper

Armin
  • 15,582
  • 10
  • 47
  • 64