title: Convert Google Doc to PDF using Google Script Editior
body: <p>I've been trying to convert a Google Docs file to a PDF file without having to use the download option. Below is the script I have used in the Script Editor but it doesn't seem to work. I think the error is after the IF statement.</p>
  
  <pre class="lang-js prettyprint-override"><code>function convertPDF() {
    doc = DocumentApp.getActiveDocument();
    docblob = DocumentApp.getActiveDocument().getAs('application/pdf');
    var result = DocumentApp.getUi().alert(
        'Save As PDF?',
        'Save current document (Name:'+doc.getName()+') as PDF',
        DocumentApp.getUi().ButtonSet.YES_NO);
    if (result == DocumentApp.getUi().Button.YES) {
      docblob.setName(doc.getName())
      folder.createFile(docblob);
      DocumentApp.getUi().alert('Your PDF has been converted to a PDF file.');
    } else {
      DocumentApp.getUi().alert('Request has been cancelled.');
    }
  }
  </code></pre>