Reputation: 39
I know that it is possible to convert a Google Doc file to pdf using Google Apps Script.
Is there a similar syntax like the one below that works for epub?
docblob = DocumentApp.getActiveDocument().getAs('application/pdf');
Upvotes: 0
Views: 261
Reputation: 11268
This code will convert your document and save it in your Drive root folder.
You have to enable Drive API using Service button.
Enable advanced services Google Doc
function createEPubFile(fileId, filename, destination) {
var mimeType = 'application/epub+zip';
var exportLink = Drive.Files.get(fileId).exportLinks[mimeType];
const params = { headers: { authorization: `Bearer ${ScriptApp.getOAuthToken()}` } };
const blob = UrlFetchApp.fetch(exportLink, params).getBlob().setName(`${filename}.epub`);
const createdFileId = destination.createFile(blob).getId();
}
Upvotes: 4