Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

193
Views
How do I set a cell value as Print Title instead of a URL

As the title suggest, I want to be able to download the pdf file this code creates with the title I took from a cell value of its sheet. Thanks in advance!

  function printSelectedRange() {
  SpreadsheetApp.flush();
  var ss = SpreadsheetApp.getActiveSpreadsheet();
  var formS = ss.getActiveSheet();
  var range = formS.setActiveRange(formS.getRange("B7:J58"));

  var gid = formS.getSheetId();
    var printRange = objectToQueryString({
    'c1': range.getColumn() - 1 ,
    'r1': range.getRow() - 1,
    'c2': range.getColumn() + range.getWidth() -1 ,
    'r2': range.getRow() + range.getHeight() 

  });
  var url = ss.getUrl().replace(/edit$/, '') + 'export?format=pdf' + PDF_OPTS + printRange + "&gid=" + gid;

  var htmlTemplate = HtmlService.createTemplateFromFile('js');
  htmlTemplate.url = url;
  SpreadsheetApp.getUi().showModalDialog(htmlTemplate.evaluate().setHeight(10).setWidth(400),'Purchase Request by ');
}

function objectToQueryString(obj) {
  return Object.keys(obj).map(function(key) {
    return Utilities.formatString('&%s=%s', key, obj[key]);
  }).join('');
}
<html>
  <head>
    <base target="_top">
  </head>
  <body>
    <script>
  window.open('<?=url?>','_blank','width=800, height=600');
  google.script.host.close();
</script>
  </body>
</html>

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!