Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Option for get_invoice_as_pdf to return the PDF as bytes #55

Open
Sticky-Bits opened this issue Jun 30, 2021 · 2 comments
Open

Option for get_invoice_as_pdf to return the PDF as bytes #55

Sticky-Bits opened this issue Jun 30, 2021 · 2 comments

Comments

@Sticky-Bits
Copy link

Sticky-Bits commented Jun 30, 2021

Hi, it would be really useful for us if accounting_api.get_invoice_as_pdf could return the PDF as bytes, instead of saving the file to /tmp/. At the moment our code looks roughly like:

filepath = accounting_api.get_invoice_as_pdf(tenant_id, invoice_id=uuid)
with open(filepath, 'rb') as f:
    pdf_bytes = f.read()
os.remove(filepath)
return pdf_bytes

And would be nice if we could instead do something like:

return accounting_api.get_invoice_as_pdf(tenant_id, invoice_id=uuid, pdf_as_bytes=True)

To avoid fetching the PDF, saving it to file, reading the file, deleting the file and then returning the bytes.

@deepgandhi
Copy link

it would be helpful if i know the location of the file in which this code is written.

@PeterJointAU
Copy link

It would be also nice if we could instruct the function where to drop the file. Ie:

accounting_api.get_invoice_as_pdf(tenant_id, invoice_id=uuid, filename='/var/www/html/myapp/invoices/inv123.pdf')

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants