1

When printing a sheet with the print dialog (CTRL+P) a custom page size can be used. enter image description here

I'm using Google App script to generate PDFs. How do I set the page size to a custom size and specify the dimensions? This is the code I'm using:

var exportUrl = url_base + 'export?exportFormat=pdf&format=pdf' +
'&gid=' + sheetTabId + '&id=' + ssID +
'&range=' + range + 
'&size=A3' +  // paper size - How do I use a custom size and specify the dimensions?
'&scale=4' +
'&portrait=false' +
'&sheetnames=false' +
'&printtitle=false' +
'&pagenumbers=false' +
'&gridlines=false' +
'&fzr=false' +
'&top_margin=0.0' +
'&bottom_margin=0.0' +
'&left_margin=0.0' +
'&right_margin=0.0' +
'&horizontal_alignment=CENTER' +
'&vertical_alignment=MIDDLE';

There is a similar question here: How to adjust as custom size margins and paper size in script to save google spreadsheet in PDF?, but the accepted answer doesn't actually answer the question...

x-x
  • 7,287
  • 9
  • 51
  • 78

1 Answers1

1
'&size=AxB'

→ A = Width you gonna use (inch)
→ B = Height you gonna use (inch)

Note: Don't use mayus and space.
Note 2: Put both together with the "x".

Example:

'&size=2.8363636363x5.9055118110'

Equivalent to 7.2cm x 15cm

Source

Digital Farmer
  • 1,705
  • 5
  • 17
  • 67