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

Proof images: allow users to upload PDFs #513

Open
raphodn opened this issue Oct 11, 2024 · 3 comments
Open

Proof images: allow users to upload PDFs #513

raphodn opened this issue Oct 11, 2024 · 3 comments
Labels

Comments

@raphodn
Copy link
Member

raphodn commented Oct 11, 2024

Story

Some users receive their receipts through email, in a PDF format.
They currently need to take a screenshot of the receipt in order to upload it to Open Prices.

We could allow uploading PDFs instead, and transform them into images directly in the backend.

@raphodn raphodn changed the title Proof images: allow users to uploaad PDFs Proof images: allow users to upload PDFs Oct 11, 2024
@raphodn raphodn added the Proofs label Oct 11, 2024
@raphael0202
Copy link
Contributor

I gave it a try locally, it's already possible to send a PDF as a proof, which is correctly recognized as PDF by the backend (application/pdf mimetype):

$ http -vv -f POST http://127.0.0.1:8000/api/v1/proofs/upload Authorization:'Bearer raphael0202__U32031dfc-4aa1-42ba-9338-fa1007d2cbcd' file@'jzvj6BkWWT.webp;type=application/pdf' type=RECEIPT

HTTP/1.1 201 Created
Allow: POST
Connection: keep-alive
Content-Length: 398
Content-Type: application/json
Cross-Origin-Opener-Policy: same-origin
Date: Wed, 30 Oct 2024 17:13:53 GMT
Referrer-Policy: same-origin
Server: nginx/1.25.5
Vary: origin
X-Content-Type-Options: nosniff
X-Frame-Options: DENY

{
    "created": "2024-10-30T17:13:53.308943Z",
    "currency": null,
    "date": null,
    "file_path": "0001/4pF30LqQob.pdf",
    "id": 17,
    "image_thumb_path": null,
    "location": null,
    "location_id": null,
    "location_osm_id": null,
    "location_osm_type": null,
    "mimetype": "application/pdf",
    "owner": "raphael0202",
    "price_count": 0,
    "receipt_price_count": null,
    "receipt_price_total": null,
    "type": "PRICE_TAG",
    "updated": "2024-10-30T17:13:53.309166Z"
}

We can either create an image from the PDF, or support PDF display for proofs on the front-end.

@teolemon
Copy link
Member

mogrify ?

@raphodn
Copy link
Member Author

raphodn commented Oct 31, 2024

https://levelup.gitconnected.com/4-python-libraries-to-convert-pdf-to-images-7a09eba83a09

Library Stars Last version
pdf2image 1.6k 9 months ago
PyMuPDF 5.4k 2 days ago
?

Ideally 1 PDF --> 1 image (even if the PDF has multiple pages)

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

No branches or pull requests

3 participants