[英]Exporting Google Sheet as PDF with Custom Headers or Footers in Google Apps Script
I'm wondering how to add custom headers or footers to a PDF that is exported using Google Apps Script from a Google Sheet.我想知道如何将自定义页眉或页脚添加到使用 Google Apps 脚本从 Google 表格导出的 PDF 中。 I would like to add a footer that says "My Company Proprietary and Confidential" in the center of the page.
我想在页面中央添加一个页脚,上面写着“我的公司专有和机密”。
This is functionality that is available in normal PDF export from Sheets (ie File » Download as » PDF » Headers & footers » EDIT CUSTOM FIELDS), but I don't know how to replicate it with URL parameters.这是从 Sheets(即文件 » 下载为 » PDF » 页眉和页脚 » 编辑自定义字段)的普通 PDF 导出中可用的功能,但我不知道如何使用 URL 参数复制它。 I've also tried setting
'&sheetnames=true&printtitle=true'
, but this puts the sheet name and spreadsheet name in the header instead of the footer.我也试过设置
'&sheetnames=true&printtitle=true'
,但这会将工作表名称和电子表格名称放在页眉而不是页脚中。
Are there any additional URL parameters I can use to control these custom fields?我是否可以使用任何其他 URL 参数来控制这些自定义字段?
var url = 'https://docs.google.com/spreadsheets/d/'+sourceSpreadSheet.getId()
+'/export?exportFormat=pdf&format=pdf' // export as pdf / csv / xls / xlsx
+ '&size=letter' // paper size legal / letter / A4
+ '&portrait=false' // orientation, false for landscape
+ '&fitw=true' // fit to page width, false for actual size
+ '&sheetnames=false&printtitle=false' // hide optional headers and footers
+ '&pagenum=CENTER&gridlines=false' // hide page numbers and gridlines
+ '&fzr=false' // do not repeat row headers (frozen rows) on each page
+ '&gid='+sourceSheet.getSheetId() // the sheet's Id
+ '&top_margin=0.45&left_margin=0.25&right_margin=0.25&bottom_margin=0.5'; // margins
Target Footer:目标页脚:
I think the workaround would be:我认为解决方法是:
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.