Hello friends!
I am currently working on a project where I need to retrieve a PDF using the frappe.utils.print_format.download_pdf
method in ERPNext Server Script, and then send this PDF via the Telegram API.
The issue I’m encountering is that, while the download_pdf
method appears to be working as intended, it doesn’t seem to be returning the file in a way that I can store it in a variable. Consequently, I am unable to send any file to Telegram.
Here’s the code snippet that I have tried:
doc = frappe.get_doc('Sales Invoice', 'ACC-SINV-2023-00009')
document = frappe.call("frappe.utils.print_format.download_pdf", doctype="Sales Invoice", doc=doc, name="ACC-SINV-2023-00009", format="POS Invoice - Sales", no_letterhead=1)
telegram = frappe.call("send_telegram_message", reciepient_chat_ids=['585184542'], caption="Test Message from ERPNext", document=document)
For context, send_telegram_message
is a custom method that I created, which is working perfectly with other files, so I suspect the issue lies in how I’m attempting to get the PDF from the built-in download_pdf
method.
Has anyone faced a similar issue or does anyone have suggestions on how I can properly retrieve the PDF file into a variable?
Any help would be greatly appreciated!
Thank you in advance!