google apps from app engine

Mike Winter

I want to produce a Google Apps document based on a (Google doc) template stored on the users Google Drive and some XML data held by a servlet running on Google App Engine.

Preferably I want to run as much as possible on the GAE. Is it possible to run Apps Service APIs on GAE or download/manipulate Google doc on GAE? I have not been able to find anything suitable

One alternative is obviously to implement the merge functionality using an Apps Script transferring the XML as parameters and initiate the script through http from GAE, but it just seem somewhat awkward in comparison.

EDIT: Specifically I am looking for the replaceText script functionality, as shown in the Apps script snippet below, to be implemented in GAE. Remaining code is supported through Drive/Mail API, I guess..

// Get document template, copy it as a new temp doc, and save the Doc’s id
var copyId   = DocsList.getFileById(providedTemplateId)
              .makeCopy('My-title')
              .getId();
var copyDoc  = DocumentApp.openById(copyId);
var copyBody = copyDoc.getActiveSection();

// Replace place holder keys,  
copyBody.replaceText("CustomerAddressee", fullName);
var todaysDate =  Utilities.formatDate(new Date(), "GMT+2", "dd/MM-yyyy"); 
copyBody.replaceText("DateToday", todaysDate);

// Save and close the temporary document
copyDoc.saveAndClose();

// Convert temporary document to PDF by using the getAs blob conversion
var pdf = DocsList.getFileById(copyId).getAs("application/pdf"); 

// Attach PDF and send the email
MailApp.sendEmail({
    to: email_address, 
    subject: "Proposal", 
    htmlBody: "Hi,<br><br>Here is my file :)<br>Enjoy!<br><br>Regards Tony", 
    attachments: pdf}); 
Zig Mandel

As you already found out, apps script is currently the only one that can access an api to modify google docs. All other ways cannot do it unless you export to another format (like pdf or .doc) then use libraries that can modify those, then reupload the new file asking to convert to a google doc native format, which in some cases would loose some format/comments/named ranges and other google doc features. So like you said, if you must use the google docs api you must call apps script (as a content service). Also note that the sample apps script code you show is old and uses the deptecated docsList so you need to port it to the Drive api.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Google App Engine and the Google Apps Marketplace

From Dev

Google App Engine - multiple apps and multiple domains?

From Dev

Google App Engine - multiple apps and multiple domains?

From Dev

Using Google App Engine with mobile apps and a web app

From Dev

Custom Domain with Google App Engine now that Google Apps is not free anymore

From Dev

Google app engine or do i need Google apps script?

From Dev

hide app from public in Google App Engine

From Dev

How to set application wide settings for Go apps in Google App Engine?

From Dev

Google App Engine PHP suddenly stopped running apps locally

From Dev

Deploying multiple apps using same project Id in Google App Engine

From Dev

Mapping App Engine Application to NON Google Apps Domain

From Dev

Google App Engine PHP suddenly stopped running apps locally

From Dev

Google App Engine Vs. Google Apps Script (Within Business Apps)

From Dev

Setup SSL from COMODO for Google App Engine

From Dev

Flickr OAuth from Google App Engine Python

From Dev

Fetching an image from google app engine ndb

From Dev

Code push from GitHub to Google App Engine

From Dev

Migrating from Google App Engine ecosystem

From Dev

Access Xero from Google App Engine

From Dev

Connecting to Firebase from Python Google App Engine

From Dev

Upload File from App Engine to Google Drive

From Dev

Inconsistent Fetch From Google App Engine Datastore

From Dev

Call Firebase database from Google App Engine

From Dev

Access Xero from Google App Engine

From Dev

Google App Engine: Counting entries from the datastore

From Dev

Google App Engine request FROM a country

From Dev

Migrating from Google App Engine ecosystem

From Dev

Google App Engine - Get from repeated StructuredProperty

From Dev

Running Google Dataflow pipeline from a Google App Engine app?

Related Related

  1. 1

    Google App Engine and the Google Apps Marketplace

  2. 2

    Google App Engine - multiple apps and multiple domains?

  3. 3

    Google App Engine - multiple apps and multiple domains?

  4. 4

    Using Google App Engine with mobile apps and a web app

  5. 5

    Custom Domain with Google App Engine now that Google Apps is not free anymore

  6. 6

    Google app engine or do i need Google apps script?

  7. 7

    hide app from public in Google App Engine

  8. 8

    How to set application wide settings for Go apps in Google App Engine?

  9. 9

    Google App Engine PHP suddenly stopped running apps locally

  10. 10

    Deploying multiple apps using same project Id in Google App Engine

  11. 11

    Mapping App Engine Application to NON Google Apps Domain

  12. 12

    Google App Engine PHP suddenly stopped running apps locally

  13. 13

    Google App Engine Vs. Google Apps Script (Within Business Apps)

  14. 14

    Setup SSL from COMODO for Google App Engine

  15. 15

    Flickr OAuth from Google App Engine Python

  16. 16

    Fetching an image from google app engine ndb

  17. 17

    Code push from GitHub to Google App Engine

  18. 18

    Migrating from Google App Engine ecosystem

  19. 19

    Access Xero from Google App Engine

  20. 20

    Connecting to Firebase from Python Google App Engine

  21. 21

    Upload File from App Engine to Google Drive

  22. 22

    Inconsistent Fetch From Google App Engine Datastore

  23. 23

    Call Firebase database from Google App Engine

  24. 24

    Access Xero from Google App Engine

  25. 25

    Google App Engine: Counting entries from the datastore

  26. 26

    Google App Engine request FROM a country

  27. 27

    Migrating from Google App Engine ecosystem

  28. 28

    Google App Engine - Get from repeated StructuredProperty

  29. 29

    Running Google Dataflow pipeline from a Google App Engine app?

HotTag

Archive