Getting GoogleDoc via API and creating PDF substitution using native text

I am wondering if it is possible to get a simple GoogleDoc (via the python gdata client) and render a PDF, replacing some custom # [PLACE_HOLDERS] with its own information.

+3
source share
1 answer

Found what I was looking for. The problem was that I was trying to use DocsService (v1 API) instead of DocsClient (v2).

WARNING . AppEngine's gdata / OAuth examples are deprecated - http://code.google.com/p/gdata-python-client/source/browse/samples/oauth/oauth_on_appengine/main_hmac.py .

To get the updated version , check this link (this is for Django, but you only need to change the request / response) - http://pamelafox-samplecode.googlecode.com/svn/trunk/spreadsheetsimporter/importer/views.py

So, after changing the Oauth method to a newer version, I managed to get the contents of the file in HTML, DOC, PDF, TXT, etc. Just change exportFormat.

In the future, if someone needs:

_client = gdata.docs.client.DocsClient('My-Prety-App-v1')
# Set your prefered auth method
# ...
entry = _client.GetDoc('document:XXXXXXXXXXXXXXXXXXXXXXXXXXXXXX')
exportFormat = 'html'
content = _client.GetFileContent(uri=entry.content.src + '&exportFormat=' + exportFormat)
self.response.out.write(content)
0
source

Source: https://habr.com/ru/post/1792591/


All Articles