How to use Google Docs for Mailer templates?
Asked Answered
L

3

15

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?

LiveDocX is providing these features but I think docs are not share-able.

Laughing answered 25/1, 2010 at 6:4 Comment(2)
I use iText to fill out a PDF template and then email that off. Its a bit of fiddling to get the values in the correct spots but if your template doesnt change much, then thats one option.Clothe
If no answer is accepted the bounty is cut in half and the highest voted answer is selected and cannot be changed. Is there feedback to the answers below that you could provide to help us better answer your question?Fingerstall
F
2

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.

Fingerstall answered 28/1, 2010 at 20:3 Comment(3)
@Jackson Miller : Is copying the doc mentioned in step2 necessary? Isn't it possible to change few variables directly in template doc, like we can insert rows in excelsheet without copying it? Or is there something I'm missing here?Laughing
That depends on the use case. If you are wanting to share the docs online with other users then you need a copy. If however you are just wanting to export the PDF (to store yourself or mail to someone) then there is no need to copy.Fingerstall
Regarding the Step 3) ... as I could see it from the docs, it is possibly only to replace the complete document. Things like 'search and replace' (in order to replace template variables) are not available via API.Nimble
G
0

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.

Greasewood answered 28/1, 2010 at 16:25 Comment(0)
R
-1

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 ...

Rummer answered 27/1, 2010 at 7:37 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.