使用此代码,我可以有效地从Google工作表导出为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文件,我将google sheet设置为0”边距,但是python导出默认为一些典型的边距。