google-apps-scriptgoogle-sheetsurlfetchexport-to-pdf

Modify google sheet paper size


This is my first time to use a script in google sheet. I saw some codes online and I just want to know if how can I modify the paper size of the code below. The legal size here in our country is 8.5 x 13.

  var exportUrl = url.replace(/\/edit.*$/, '')
      + '/export?exportFormat=pdf&format=pdf'
      + '&size=LEGAL'
      + '&portrait=true'
      + '&fitw=true'       
      + '&top_margin=0.5'              
      + '&bottom_margin=0.5'          
      + '&left_margin=0.5'             
      + '&right_margin=0.5'           
      + '&sheetnames=false&printtitle=false'
      + '&pagenum=false'
      + '&gridlines=true'
      + '&fzr=FALSE'      
      + sheetParam
      + rangeParam

Solution

  • the size 8.5 x 13 inch is called "Folio"

    If this is the size to which you want to export, you need to simply assign it to size instead of LEGAL:

      var exportUrl = url.replace(/\/edit.*$/, '')
          + '/export?exportFormat=pdf&format=pdf'
          + '&size=folio'
          + '&portrait=true'
          ...