My code currently searches for a predefined start tag in google document, and locates a corresponding ending tag. The position of the tags is retained in a variable.
Next the code runs through and copies all of the elements between the tags into a second google document. This works as expected.
However, the data held in the source document has grown to be 100s of pages. Therefore the script searching for the tags takes a few more seconds than expected. This increases the time it takes to find the tags and copy the elements between them.
My solution to this is to have a master script that picks up the elements once and stores them in something like Firebase or Firestore. Then I can access the elements directly from the DB. I have tried several approaches to store Google document elements.
This is how I get the elements.
var element = sourceDoc.getChild(j).copy(); // Gets Paragraph etc.
My attempts include.
- Store the element in an array and then iterate the array - works fine within the same run time.
- Store the element in the document cache - does not work.
- Try to store the element as a blob - don't know how to do correctly.
- Stringify the element and save in document cache - does not work.
Has anybody tried saving Google document elements for use a later date?