我可以使用此代码从谷歌表格有效地导出为 PDF
from pydrive.auth import GoogleAuth
from pydrive.drive import GoogleDrive
gDriveCreds="mycreds.txt"
gauth = GoogleAuth()
GoogleAuth.DEFAULT_SETTINGS['client_config_file'] = "client_secrets.json"
gauth.LoadCredentialsFile(gDriveCreds)
if gauth.credentials is None:
gauth.LocalWebserverAuth()
elif gauth.access_token_expired:
gauth.Refresh()
else:
gauth.Authorize()
gauth.SaveCredentialsFile(gDriveCreds)
drive = GoogleDrive(gauth)
file_obj = drive.CreateFile({'id': 'sfkldjlfsdkjfgdklj'})
file_obj.GetContentFile('temp.pdf', mimetype='application/pdf')
但我想不出一种方法来创建我想要的 0" 边距的 pdf。我将谷歌表设置为 0" 边距,但 python 导出只是默认为一些典型的边距。