Closed rklett closed 5 months ago
So it seems to me this is actually multiple features working together and it would be best to implement all of these, although only #3 is really necessary for this feature.
1: Let Catima handle share intents for images (so that sharing an image to Catima works).
I can't really help with the first two but the third one, I've seen similar features in https://github.com/michaeltroger/greenpass-android. Unfortunately, that app keeps crashing for me on my new phone after I imported a PDF but I had it sort of working on an older phone.
Poking around, I think it uses https://github.com/TomRoush/PdfBox-Android for the PDF handling. I'm not a developer though so my contributions probably end here. I'll keep an eye out in case anything comes up that I might be able to help with.
@rklett you might want to check out https://github.com/ligi/PassAndroid, which is actually made for tickets and also supports import of PDF tickets. HTH
Quoting from #977, noting only PDF import related mentions:
Treating PDF files as images and letting them go through the cropper, making sure that multi-page PDF files will stay multi-page (probably by just putting all pages below or next to each other). (Side note: Supporting PDFs as image input also has the benefit of being able to support them in "Scan Barcode -> Select image from gallery" for new barcodes to be added, such as for https://github.com/CatimaLoyalty/Android/issues/907)
Either 1 picture per PDF (collate all pages into 1 image), or an image for each page - the first suggestion works best if you have multiple PDFs, but the latter works best when you only have 1 PDF, so you can swipe over each individual image/page. It's an implementation detail so I'll leave it to be discussed in the appropriate task.
One or two pages are easy enough, but if you get 5 or more pages it'll look awful.
Potential Libraries for the implementation:
I was trying to convert my PDF on device (though ended up using my PC, as it was easier), and found 2 open-source apps which advertise this functionality:
- Swati4star/Images-to-PDF which is on-going, but for me it bugs out, and https://github.com/Swati4star/Images-to-PDF/issues/1083.
- scoute-dich/PDFCreator which archived for like 5 years, but worked quite well, but the UI, is poor tbh (doesn't matter, the library is what counts) - if 1, had vulnerabilities, I presume this would too...
Let's put those libraries in the new task as links and see if they're the best of if there are other options. Archived for 5 years sounds like it's asking for trouble though.
Oh yeah, that reminds me, I found https://developer.android.com/reference/android/graphics/pdf/PdfRenderer.html yesterday. PDF reading right in Android core libraries. That would definitely be the best option if possible.
But first it needs checking if Google's new Android 13 restrictions on opening files hasn't broken the ability to open non-media-files: #979
this would be a massive step forward for this app's actual use as a ticket manager as well as membership cards.
I don't know if its an use case that this app is whiling to support, but currently in my country I can use PDF's with QR codes as valid documents (IDs, vaccination cards, car license etc).
So Catima has being a great way to concentrate all my documents, except that I can't attach the original PDF's to the document if some official asks for it. Currently I converted the PDFs to images and attached to Catima, but sometimes they ask for the PDF itself. So I'm saving that in my phone also, but would be great to have some sort of "Attachments" session that allows the user to upload stuff related to that card.
maybe we can just use an "attach" option, for any kind of document, wich opens a new app.
I'd like to be able to use Catima to store and display e-tickets which have been provided in PDF format with embedded QR codes. I suppose the workaround for this is to either take a screenshot of the PDF on my phone and import that or to scan the QR code off my computer screen. Both of these are a bit of a hassle that I'd like to avoid if Catima supported importing a PDF.
Maybe something to consider is that usually these PDFs come with one page per ticket with each page/ticket having a separate QR code. I expect this complicates things more than just adding a PDF reading library but we can set the aside for now.