Dec 11, 2017 - As pointed out here: To 'Save as PDF' instead of 'Download as PDF', one should: File > Print; Change destination to Google Drive.
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.
It is failing because the folder is not defined. If you replace it with DriveApp, the PDF will be created in the root folder and your function would work. You can also show the full URL in the message box.
To save the PDF in the original directory:
And add this generic function