有没有一种方法可以将API PDF代码响应转换为Google App脚本中的PDF?

时间:2020-05-17 10:27:50

标签: google-apps-script pdf-conversion

使用API​​,我可以获得发票的PDF编码-在python中,我可以直接在pdf中编写此响应字符串,然后创建格式化的文档。

是否可以通过Google App脚本将此PDF代码写入PDF并获取pdf格式的文件?

Python代码示例(我在Google App脚本中也需要相同的代码)

access_token

这是Google应用程序脚本。

我收到错误-从文本/纯文本到应用程序/ pdf的转换失败。

    for list_invoice in list_invoices['invoices']:
        response = requests.get('https://books.zoho.com/api/v3/invoices/'+str(list_invoice['invoice_id'])+'?organization_id=41285962&accept=pdf',
            headers = {
            "Content-Type" : "application/x-www-form-urlencoded;charset=UTF-8",
            "Authorization" : "Zoho-oauthtoken "+authoken
            }
            )
        #getting pdf response - writing pdf encoding and making respective pdf invoice on the desktop

        with open('/Users/office/Desktop/'+str(invoice_number_hellocash_zoho)+'.pdf', 'wb') as f:
            f.write(response.content)

0 个答案:

没有答案
相关问题