編集:編集には時間がかかるため、回答を追加しました(回答2を参照)
ドキュメントのマージに関する以前の投稿に続いて、スクリプトが機能するようになりました(Henriqueに感謝します;)が、まだ1つの小さな問題があります。 。これを行う簡単な方法が見つかりません。スクリプトは次のようになります:
function mergeDocs(docIDs) { // parameter docIDs is an array of Doc IDs
var baseDocname = DocumentApp.openById(docIDs[0]).getName();// typical name = IMPRESSION_page_07_07-06-2012__20:57
var modelDoc = DocsList.getFileById(docIDs[0]);
var newmodelName=baseDocname.substr(0,11)+'multipage'+baseDocname.substring(18);
var baseDocId = DocsList.copy(modelDoc,newmodelName).getId();// make a copy of firstelement and give it new basedocname build from the serie(to keep margins etc...)
var baseDoc = DocumentApp.openById(baseDocId)
var body = baseDoc.getActiveSection();
//
for( var i = 0; i < docIDs.length; ++i ) {
var otherCopy = DocumentApp.openById(docIDs[i]).getActiveSection();
var totalElements = otherCopy.getNumChildren();
for( var j = 0; j < totalElements; ++j ) {
var element = otherCopy.getChild(j).copy();
var type = element.getType();
if( type == DocumentApp.ElementType.PARAGRAPH )
body.appendParagraph(element);
else if( type == DocumentApp.ElementType.TABLE )
body.appendTable(element);
else if( type == DocumentApp.ElementType.LIST_ITEM )
body.appendListItem(element);
else
throw new Error("According to the doc this type couldn't appear in the body: "+type);
}
body.appendPageBreak(); // if content length is too short avoids breaking page layout
}
}
'PageBreak'は(時々)空白のページを引き起こします、私はそれを知っています(!)、しかし完璧なページレイアウトを維持する必要があります(私はこのドキュメントでラベルを印刷しています)。ここに典型的な例へのリンクがあります