Hello everyone!
I am facing an unexpected result when I try to convert a Google Doc to PDF. I already noticed that the error occur when the file has more than 150 pages.
Even if I open the file in Google Doc I can't convert using the path File >> Download As >> PDF. For every other format I am succeeded in convert.
Here are the two functions that I am using, but with the same error result:
function convertToPDF_v1(prmDocID) {
var doc = DocumentApp.openById(prmDocID)
var nomeDoc = doc.getName();
var pdf = doc.getAs('application/pdf').setName(nomeDoc + ".pdf");
var arqPDF = DriveApp.createFile(pdf);
var pdfID = arqPDF.getId();
return pdfID;
}
function ConvertToPDF_v2(fileID)
{
const FileName = DriveApp.getFileById(fileID).getName();
var blob = UrlFetchApp.fetch(url, {headers: {authorization: `Bearer ${ScriptApp.getOAuthToken()}`}}).getBlob();
var newFile = DriveApp.createFile(blob.setName(FileName));
return newFile.getId();
}
Any clue and guidance to overcome this error I will really appreciate!!
Thanks,
Fernando