How to Google Docs to make a dynamic parameter substitution in a document via the API?

The chief set the task: there are documents in Google Docs with placeholders like {{username}}, for which you need to make a wrapper in PHP.

The bottom line: when you click on the link on the project page to be generated and downloaded document in RTF format. Ie is a request to Google API Docs, the document is pre-loaded in memory, substitute the required parameters, then it is issued to the user.

Tried to do it via an intermediate step: i.e. a downloadable document in html format, using preg_replace inline parameters generated a new document and using the library PhpWord send in the results. But the problem was that PhpWord can't create a new Doc and gives error. Therefore, we hope that such operations can be done solely by means of the API.

Is it real? Prompt please who knows.
June 7th 19 at 15:01
1 answer
June 7th 19 at 15:03
I have done differently. There is a library docxtpl in python. You can very easily replace the values in the DOX file (as format string). Save a new file, and then send the file to gdrive

php not for files =)

doc = DocxTemplate(path_to_template)
context = {
 'theme': theme,
 'regnumber': regnumber,
 'address': address,
 'date': date_created.strftime("%d.%m.%Y")
okay, sorry - Rosanna.Ratke19 commented on June 7th 19 at 15:09
Payton is not a channel, we're at work don't use it vaabsche. Although they did dabble in my spare time) - Jessyca.McDermott commented on June 7th 19 at 15:06

Find more questions by tags APIGoogle