Skip to content

Option for get_invoice_as_pdf to return the PDF as bytes #55

Open

Description

@Sticky-Bits

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.

Activity

  1. deepgandhi commented on Feb 4, 2022

    @deepgandhi

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

  2. PeterJointAU commented on May 17, 2022

    @PeterJointAU

    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')

  3. vncntk commented on Dec 1, 2025

    @vncntk

    Is there a new feature for this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions