Google Docs to PDF
1. Overview
This plugin is used to convert templated google docs to PDF.
2. Getting started
2.1 Setting up the docs
The first steps are to create the template and mapping data. The detailed docs to which will be added in following week.
2.2 Setting up the google services.
- Setup the Google Credentials for service account credentials on google developer console .
- Copy Service account json credential in GoogleDocPlugin folder and name it as gcs-creds.json.
- Enable the following API => Google Docs, Google Sheets, Google Cloud Storage.
- Creating a Oauth2 access token json from Google developer console.
- Copy Oauth2 Credential json file (client_secret.json) and paste it in GoogleDocPlugin and name it as credentials.json.
- Create a Google App Script and delete all code and copy code from google_app_script_code.js file in GoogleDocPlugin and paste it on script editor and then publish it as a deploy as web app.Deploy as web app pop up opens and select "Anyone,Even Anoynmous" in Who has access to the app . (See network tab on Google Chrome dev console if you have issues with it)
- Update the url in googledoc-config.json.
- Create Google Cloud Storage Bucket and update the bucket name and GOOGLECLOUDBASEURL in googledoc-config.json.
2.3 Fixing the config file
The config file containes all the credentails and configurations that are required for the plugin to work. A sample config file is show below. Please duplicate this and fill the entried based on whatever you have and remove the documentation (json doesn't allow docstrings)
2.4 Running the system.
From the root folder run the following command to start converting data to PDF. python src/pdfbase/main.py
3. Limitations
- The template document should be available on the authenticated account’s drive. It won’t work if the doc is shared as read/write with the authenticated account.
- If the options are using apostrophe then python and app script aren't parsing it. Eg. Teacher’s were good, is working great. But Teacher's are good, is not working well.
- The image dimensions in app script are fixed 1:1.
- The intermediate google docs are created in the same location as that of template doc.
- If app script failed due to any runtime error then a junk google doc is still created.
- Google App script usage limitations (url fetching) (https://developers.google.com/apps-script/guides/services/quotas#current_limitations)
4. FAQs
Feel free to write into tech@samagragovernance.in in case you have questions, feedback or want to know more!
5. Coming Soon
Please review the following section to get information about planned updates to this module.