Generate PDF for beneficiary form¶
Please go to Livelihoods Monitoring Folder > OTHER > 4_Trainings > Livelihoods guides > PDM Master Surveys and find PRINTOUT CUSTOMISED-Livelihoods Beneficiary Survey file
Please follow the instructions and explanations on README sheet:
Manual Modifications
Automatic Modifications
The script is located in the same file, please fo to Tools > Script Editor
In order to fix the known format issues with the labels, it’s required to run one-by-one all the following functions:
- 
BR()¶ The function removes <br> tag from labels
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20  | function BR() {
  var thisid = SpreadsheetApp.getActiveSpreadsheet().getId();
  var ss = SpreadsheetApp.openById(thisid);
  var sheet= ss.getSheetByName("survey");
  var x=sheet.getRange(1,1,sheet.getLastRow(),sheet.getLastColumn()).getValues();
  
  for(iy=0;iy<x.length;iy++)
  {
    for(ix=0;ix<x[0].length;ix++)
    {
      
      try{x[iy][ix]=x[iy][ix].replace(/<br>/g,"");
          x[iy][ix]=x[iy][ix].replace(/<\/br>/g,"");
          x[iy][ix]=x[iy][ix].replace("###<span","#<span");
          x[iy][ix]=x[iy][ix].replace("#<span","###<span");
         }catch(e){}
    }
  }
  sheet.getRange(1,1,sheet.getLastRow(),sheet.getLastColumn()).setValues(x);
}
 | 
- 
deletespace()¶ The function removes n tag from labels
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29  | function deletespace() {
  var thisid = SpreadsheetApp.getActiveSpreadsheet().getId();
  var ss = SpreadsheetApp.openById(thisid);
  var sheet= ss.getSheetByName("survey");
  var x=sheet.getRange(1,1,sheet.getLastRow(),sheet.getLastColumn()).getValues();
  
  for(iy=0;iy<x.length;iy++)
  {
    for(ix=0;ix<x[0].length;ix++)
    {
      
      try{var y=x[iy][ix].match(/>.*?\n.*?</g);
          
          if(y!=null)
          {
            for (i=0;i<y.length;i++)
            {
              if(y[i].match(/>\n</)!=null){continue;}
              Logger.log(y[i]);
              var yy=y[i].replace(/\n/,"");
              x[iy][ix]=x[iy][ix].replace(y[i],yy);
            }
          }
          
         }catch(e){}
    }
  }
  sheet.getRange(1,1,sheet.getLastRow(),sheet.getLastColumn()).setValues(x);
}
 | 
- 
insertspace()¶ The function inserts n tag
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17  | function insertspace() {
  var thisid = SpreadsheetApp.getActiveSpreadsheet().getId();
  var ss = SpreadsheetApp.openById(thisid);
  var sheet= ss.getSheetByName("survey");
  var x=sheet.getRange(1,1,sheet.getLastRow(),sheet.getLastColumn()).getValues();
  
  for(iy=0;iy<x.length;iy++)
  {
    for(ix=0;ix<x[0].length;ix++)
    {
      
      try{x[iy][ix]=x[iy][ix].replace(/></g,">\n<");
         }catch(e){}
    }
  }
  sheet.getRange(1,1,sheet.getLastRow(),sheet.getLastColumn()).setValues(x);
}
 | 
- 
Note()¶ The function removes n tag for Note
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17  | function Note() {
  var thisid = SpreadsheetApp.getActiveSpreadsheet().getId();
  var ss = SpreadsheetApp.openById(thisid);
  var sheet= ss.getSheetByName("survey");
  var x=sheet.getRange(1,1,sheet.getLastRow(),sheet.getLastColumn()).getValues();
  
  for(iy=0;iy<x.length;iy++)
  {
    for(ix=0;ix<x[0].length;ix++)
    {
      
      try{x[iy][ix]=x[iy][ix].replace(/NOTE: <\/span>\n/g,"NOTE: </span>");
         }catch(e){}
    }
  }
  sheet.getRange(1,1,sheet.getLastRow(),sheet.getLastColumn()).setValues(x);
}
 | 

