I am trying to generate a report in a Google doc from a template file. When it copies the document it resets all of the formatting to the defaulted for the user and not what the format in the original doc is. I’ve tried the following to try and set the formatting on a both the document, tableRow and tableCell level though when the report is created the line spacing is 1.5 and there is a space after paragraph
var style = {};
style[DocumentApp.Attribute.SPACING_AFTER] =0;
style[DocumentApp.Attribute.SPACING_BEFORE] =0;
style[DocumentApp.Attribute.LINE_SPACING]=1;
var newrow= tables[2].insertTableRow(n).setBold(false).setAttributes(style);
if(j==0){
newrow.insertTableCell(0,reportDate).setPaddingBottom(0).setPaddingTop(0).setAttributes(style);
}
else{
newrow.insertTableCell(0,'').setPaddingBottom(0).setPaddingTop(0).setAttributes(style);
}
newrow.insertTableCell(0,values1[rowId1][1]+' '+values1[rowId1][2]).setPaddingBottom(0).setPaddingTop(0).setAttributes(style);
newrow.insertTableCell(0,'').setPaddingBottom(0).setPaddingTop(0).setAttributes(style);
doc.editAsText().setAttributes(style);
any suggestions on how to have the report follow these attributes?
As the set attributes was not setting the attributes and you can not cast any of the elements as paragraphs I resolved this problem by getting all of the paragraphs and setting them manually by adding this at the end