title: Google sheet create pdf from another sheet ID
body: <p>Hi how could this code be modified to create a PDF file from another worksheet instead of the active open worksheet.
  Here's part of the code I'm using and it works but I would like to create a PDF from another worksheet ID</p>
  
  <p>Thanks</p>
  
  <pre><code>   var source = SpreadsheetApp.getActiveSpreadsheet();
     var spreadsheet = spreadsheetId ? SpreadsheetApp.openById(spreadsheetId) : SpreadsheetApp.getActiveSpreadsheet();
     var spreadsheetId = SpreadsheetApp.getActiveSpreadsheet().getId();
     var ticketnum = source.getSheetByName("Print Page").getRange('X1').getValue();
     var body = 'Attached is your copy'
     var Client = source.getSheetByName("Print Page").getRange('O5').getValue();
     var Cons = source.getSheetByName("Print Page").getRange('T4').getValue() ;
     var jobN = source.getSheetByName("Ticket PDF").getRange('G9').getValue() ;
     var mailTo = source.getSheetByName("Print Page").getRange('Z1').getValue() ;
     var folder = DriveApp.getFoldersByName('Ticket').next();
     var token = ScriptApp.getOAuthToken();
     var ssID = spreadsheetId;
     var url = "https://docs.google.com/spreadsheets/d/"+ssID+"/export"+
                                                      "?format=pdf&amp;"+
                                                       '&amp;portrait=true' + 
                                                       '&amp;fzr=true' +  
                                                       '&amp;fitw=True' + 
                                                       //'&amp;scale=4' +
                                                       '&amp;top_margin=0.25' + 
                                                       '&amp;bottom_margin=0.25' + 
                                                       '&amp;left_margin=0.25' +
                                                       '&amp;right_margin=0.25' +
                                                       '&amp;horizontal_alignment=CENTER' +  
                                                       '&amp;gridlines=false'+
                                                       '&amp;sheetnames=False';
  
  
  
       var response = UrlFetchApp.fetch(url, {
      headers: {
          'Authorization': 'Bearer ' + token
        }
      });
  
      var pdf = response.getBlob().setName( Client + "  " + ticketnum + " @ " + jobN + "  "  + '.PDF');
      folder.createFile(pdf)
  </code></pre>