Skip to content

Instantly share code, notes, and snippets.

@MartinGonzalez
Last active January 13, 2019 23:05
Show Gist options
  • Save MartinGonzalez/7739e362e8ca0ac6ed3e7edc45e233b0 to your computer and use it in GitHub Desktop.
Save MartinGonzalez/7739e362e8ca0ac6ed3e7edc45e233b0 to your computer and use it in GitHub Desktop.
Download PDF with Google Drive API
const downloadFileAsPdf = (googleDriveFileId) => {
const drive = google.drive({ version: 'v3', auth: 'YOUR_API_KEY' });
const fileStream = fs.createWriteStream('./output.pdf')
drive.files.export({ fileId: googleDriveFileId, mimeType: 'application/pdf' }, { responseType: 'stream' }, (err, res) => {
res.data.pipe(fileStream);
})
}
//https://docs.google.com/presentation/d/HERE_IS_THE_FILE_ID
const slideId = "GOOGLE_DRIVE_FILE_ID"
downloadFileAsPdf(slideId)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment