Home > Enterprise >  How to remove page name and page number? In auto generate PDF Google App Script
How to remove page name and page number? In auto generate PDF Google App Script

Time:09-26

So, I'm using app script to do auto generate PDF in spreadsheet. But when I execute the code, the result is automatically adding page name on left-top corner and page number on left-down corner. Is it possible to remove the page name and and page number? Here is the image Here is the code:

function createblobpdf(sheetName, pdfName) {
var sourceSpreadsheet = SpreadsheetApp.openByUrl("https://docs.google.com/spreadsheets/d/1IaKnN8GIaLLyNZBMNBKTvml5V1pBzUjXx60BH_bKEdw/edit#gid=1194998923");
  var sourceSheet = sourceSpreadsheet.getSheetByName("PAGENAME");
  var url = 'https://docs.google.com/spreadsheets/d/'   sourceSpreadsheet.getId()   '/export?exportFormat=pdf&format=pdf' // export as pdf / csv / xls / xlsx
         '&size=A4' // paper size legal / letter / A4
         '&portrait=true' // orientation, false for landscape
         '&fitw=true' // fit to page width, false for actual size
         '&sheetnames=true&printtitle=false' // hide optional headers and footers
         '&pagenum=RIGHT&gridlines=false' // hide page numbers and gridlines
         '&fzr=false' // do not repeat row headers (frozen rows) on each page
         '&horizontal_alignment=CENTER' //LEFT/CENTER/RIGHT
         '&vertical_alignment=TOP' //TOP/MIDDLE/BOTTOM
         '&gid='   sourceSheet.getSheetId(); // the sheet's Id

CodePudding user response:

You will need to set the following two parameters:

  • pagenumbers = false
  • sheetnames = false
function createblobpdf(sheetName, pdfName) {
  var sourceSpreadsheet = SpreadsheetApp.openByUrl("https://docs.google.com/spreadsheets/d/1IaKnN8GIaLLyNZBMNBKTvml5V1pBzUjXx60BH_bKEdw/edit#gid=1194998923");
  var sourceSheet = sourceSpreadsheet.getSheetByName("PAGENAME");
  var url = 'https://docs.google.com/spreadsheets/d/'   sourceSpreadsheet.getId()   '/export?exportFormat=pdf&format=pdf' // export as pdf / csv / xls / xlsx
         '&size=A4' // paper size legal / letter / A4
         '&portrait=true' // orientation, false for landscape
         '&fitw=true' // fit to page width, false for actual size
         '&sheetnames=false&printtitle=false' // hide optional headers and footers
         '&pagenumbers=false&gridlines=false' // hide page numbers and gridlines
         '&fzr=false' // do not repeat row headers (frozen rows) on each page
         '&horizontal_alignment=CENTER' //LEFT/CENTER/RIGHT
         '&vertical_alignment=TOP' //TOP/MIDDLE/BOTTOM
         '&gid='   sourceSheet.getSheetId(); // the sheet's Id
  console.log(url);
}
  • Related