2

Just to clarify this is a Google Active Script.

Read Google Doc File ( this is a template with place holders and formatting ( bod, tabs, underline etc ) Place holders are {placeholderName} I use Body.replaceText('{placeholderName}', placeholderName) this works fine. The data that is inserted is contained within a Google Spreadsheet (that works fine too) I am only trying to maintain formatting in the template file that is modified and then appended to the final file.

 var SerialLetterID = DriveApp.getFileById('google_doc_id').makeCopy('filename').getId(); 

var fBody = DocumentApp.openById(SerialLetterID);

 // an independent copy of the template ( with formatting )
var Template = fBody.getBody().copy(); 

After the data replaces the placeholders

// insert a pageBreak
fBody.getBody().appendPageBreak();

/* 
 this is where I'm getting the issues.. everything works but the getText()
 removes all formatting.  I looked for a getCopy() or something of the like
 but nothing like that seems to exist.  So, in OOP google style how would I     
 copy the page, maintain formatting in the same manner as getText() works?
*/
// add template with placeholders 
fBody.getBody().appendParagraph(Template.getText());

I hope that I explained what I'm trying to do.

Matt
  • 45,022
  • 8
  • 78
  • 119
  • How is your question different from [this one](http://stackoverflow.com/questions/19987101/how-to-copy-the-content-of-a-google-docs-text-file-to-another-google-text-docume)? – Mogsdad Jan 29 '16 at 16:09
  • Thank you.. I hunted and found several but none that were this direct. I only have one question, I added the couple lines of code, but apparently the document has to be bound to the script. All the examples I have read and tutorials come from the perspective of using the UI Tools > Script editor. This is being done entirely in a stand alone script. How, what function binds my 'virtual' file to the script? – Sean Schroeder Jan 29 '16 at 16:48
  • Figured it out... Thanks for pointing me in the right direction. – Sean Schroeder Jan 29 '16 at 17:13
  • A good outcome, then. I wasn't sure you were describing the same problem. – Mogsdad Jan 29 '16 at 17:33

0 Answers0