How to use Google Docs for Mailer templates?
-
22-09-2019 - |
Question
Is it possible to use Google Docs for Mailer templates? How can I change template variables via API? Basically, I want to keep a template on Google and export it as a PDF file after changing few variables like name, address etc. Is it possible to do it completely via API in PHP?
EDIT
LiveDocX is providing these features but I think docs are not share-able.
EDIT
Is it true that even if no answer is acceptable I've to accept some answer because of bounty?
Solution
Not quite sure that I understand the use case here, but I think what you are wanting to do it to generate a series of PDFs that have been personalized with info like name and address to then mail out as shared web accessible documents on Google Docs.
If that is right, then yes I think you should be able to do that.
Step 1) Create the template in Google Docs.
Step 2) Copy the document using the API here: http://code.google.com/apis/documents/docs/3.0/developers_guide_protocol.html#copying_documents
Step 3) Edit the new document with the personalized info using the API here: http://code.google.com/apis/documents/docs/3.0/developers_guide_protocol.html#updatingchanging_documents_and_files
Step 4) Share the new document with the appropriate person using the API here: http://code.google.com/apis/documents/docs/3.0/developers_guide_protocol.html#managing_sharing_permissions_of_resources_via_access_control_lists_acls
If you are specifically wanting the customized PDF the API for exporting is here (but I don't think you can share it as a PDF, though you can share it as a read-only document): http://code.google.com/apis/documents/docs/3.0/developers_guide_protocol.html#downloading_documents_and_files
Hope that helps.
OTHER TIPS
I am not sure if this is exactly what you are looking for, but in section 5 of this link it describes how to send out auto-generated e-mails based on a template/spreadsheet combo:
http://www.google.com/google-d-s/scripts/mail_merge.html#section5
You can store one document as a template having some meta-symbols (like {0}) to be substituted with real values. Then retrive that document from google docs using API and substitute all metas with values. Then save the result of substitution as a new document, export it as PDF and remove.
All these things should be available through API.
Here is something from forum about custom private templates
http://www.google.com/support/forum/p/Google+Docs/thread?tid=40b028a54a1fc981&hl=en
I think it should be possible to create private template by hand, and then edit it through API - create new document based on your private template (probably any saved document), edit it, save it and export as PDF
Hope it helps
you could just download the docs ( code.google.com ) and use preg_replace_callback
or something like that to do the template replacement in your php code, then upload it again (as a copy), but performancewise this would suck ...