Reputation: 59
This function
function appendiNote() { //appende tutte le note ma senza formattazione..
var note = DocumentApp.getActiveDocument().getFootnotes();
for (var i = 0; i < note.length; i++){
var par = note[i].getFootnoteContents();
DocumentApp.getActiveDocument().getBody().appendParagraph((i+1)+par.getText());
}
appends all notes inside the body document, but the formatting of the gets lost ....how can I do it so it gets formatted as well (word by word, i need it to preserve italic and bold words)?
Upvotes: 0
Views: 122
Reputation: 4344
Footnotes are objects in Google, so you need to access each object and extract the string text. You need to use .getFootnoteContents()
in conjunction with the .copy()
method to copy the properties of the Footnote
.
Change your code to:
function appendiNote() {
// Gets all footnotes in the document as an iterable array
var notes = DocumentApp.getActiveDocument().getFootnotes();
// iterate through the notes array
for (var i = 0; i < notes.length; i++) {
// for each item, get the contents of the object
var note = notes[i].getFootnoteContents();
// create a deep copy of the object, which includes styles.
var par = note.getChild(0).copy();
// Append the footnote, including styles, as a paragraph in the body of the doc.
DocumentApp.getActiveDocument().getBody().appendParagraph(par);
}
Upvotes: 1