title: App Script Google Sheet creating multiple PDFs from 20+ sheets without it timing out
body: <p>I have the below which hides all tabs but the current and exports to a pdf in a specified drive folder. Then unhides all, cycles to the next and repeats. Works fine but want to be able to scale the tab to fit to one page.</p>
  <p>Other methods using URLfetchapp allow for scaling but it causes time outs by too many requests.</p>
  <pre><code>function Exportpdf() {
    var spreadsheet = SpreadsheetApp.getActive();
    nextSheet()
    exportSheet()
    if (SpreadsheetApp.getActiveSheet().getName()=='Data'){}
    else {Exportpdf()}
  };
  
  function nextSheet() {
    var ss = SpreadsheetApp.getActiveSpreadsheet();
    var numSheets = ss.getSheets().length;                // number of sheets
    var activeSheetIndex = ss.getActiveSheet().getIndex() - 1;   // see below 
    var newSheetIndex = (activeSheetIndex + 1) % numSheets;   // add 1; wrap around
    ss.setActiveSheet(ss.getSheets()[newSheetIndex]);  
  }
  
  function exportSheet() {
  var actualSheetName = SpreadsheetApp.getActiveSpreadsheet().getActiveSheet().getName();
  var ss = SpreadsheetApp.getActiveSpreadsheet();
  var sheets = ss.getSheets();
  for (var i = 0; i &lt; sheets.length; i++) {
  if (sheets[i].getSheetName() !== actualSheetName) {
  sheets[i].hideSheet()
  }
  }
  var pdfName = (SpreadsheetApp.getActiveSpreadsheet().getName() + &quot; - &quot; + SpreadsheetApp.getActiveSheet().getName());
  var newFile = DriveApp.createFile(ss.getBlob().getAs('application/pdf').setName(pdfName));
  for (var i = 0; i &lt; sheets.length; i++) {
  sheets[i].showSheet()
  }
  newFile.moveTo(DriveApp.getFolderById(&quot;11ZLhYZgpLuq5VWB90TdGbDrOUzP2SUlr&quot;));
  }
  </code></pre>