Report Lab not producing/saving a pdf while using Google Colab/Google Drive/ipynb

Viewed 24

I'm looking to use Report Lab within a Google Colab but it doesn't seem to generate any files.

This is the simple code I'm running. No "hello.pdf" exists in my Google Drive.

from reportlab.pdfgen.canvas import Canvas
canvas = Canvas("hello.pdf")
canvas.drawString(72, 72, "Hello, World")
canvas.showPage()
canvas.save()

I have successfully mounted my Google Drive using

from google.colab import drive
drive.mount('/content/drive')

Thanks in advance for the help

1 Answers

Try specifying the full path in the call to Canvas.

canvas = Canvas("/content/drive/MyDrive/hello.pdf")
Related