Skip to content

Instantly share code, notes, and snippets.

@pshriwise
Last active January 16, 2025 21:55
Show Gist options
  • Save pshriwise/87df7fbad525d4cb2cee865829e0964f to your computer and use it in GitHub Desktop.
Save pshriwise/87df7fbad525d4cb2cee865829e0964f to your computer and use it in GitHub Desktop.
Generate a URL for PDF export of a Google slide deck
from argparse import ArgumentParser
import sys
import os
args = ArgumentParser()
args.add_argument('document_id', help='Google Slides document ID')
args.add_argument('--output', help='Content in output',
choices=('html', 'iframe', 'link', 'pdf'), default='html')
args = args.parse_args()
iframe = '<p><iframe title="embedded content" src="https://docs.google.com/presentation/d/{}/embed"' \
'width="960" height="569" allowfullscreen="allowfullscreen" webkitallowfullscreen="webkitallowfullscreen"' \
'mozallowfullscreen="mozallowfullscreen"></iframe></p>'
link_template = 'https://docs.google.com/presentation/d/{}/edit?usp=sharing'
pdf_template = 'https://docs.google.com/presentation/d/{}/export/pdf'
link_element = '<a class="inline_disabled" title="Link" href="{}"' \
'target="_blank" rel="noopener">View in Google Slides</a>'
pdf_element = '<a class="inline_disabled" title="Link" href="{}" target="_blank" rel="noopener">Download Slides as a PDF</a>'
if args.output == 'html':
print(iframe.format(args.document_id))
print('<p><strong>Click on&nbsp;</strong>&vellip;<strong> in presentation above to enable speaker notes.</strong></p>')
print(link_element.format(link_template.format(args.document_id)))
print('<span>&diams;')
print(pdf_element.format(pdf_template.format(args.document_id)))
elif args.output == 'iframe':
print(iframe.format(args.document_id))
elif args.output == 'link':
print(link_template.format(args.document_id))
elif args.output == 'pdf':
print(pdf_template.format(args.document_id))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment