Hello Guys Please VOTE !! We have found no open s...
# multiplatform
f
Hello Guys Please VOTE !! We have found no open src compose lib for pdf in KMM. We we could start developing one, should we go for 1. Build from scratch NDK Library using libharu or aosp_pdfium. 2. Use exiting stable wrapper library like andorid-pdfium for Android and PDFkit for iOS.
2️⃣ 5
1️⃣ 2
a
#1 would ensure consistent behavior on each platform, might be nice
m
You might want to have a look at https://github.com/swapnil-musale/KMP-PDF-Viewer for a start.
f
I have checked it is not lib but a project uses aproach 2
r
What is real difference between 1 and 2? In both cases you will create wrappers for some platform specific libraries.
m
I would need that for one of my next projects. Personally i would honor the difference between Android and iOS and go with option 2
Just saying: Android has no good FREE pdf library in general. Very annoying. Only the paid libs are good
j
There is one development on Android: Android 15 DP2 has "substantial improvements" to Android's built-in
PdfRenderer
. The cool thing about it, is that it will move to be a part of Play System Services, making it available back to Android 11. See https://android-developers.googleblog.com/2024/03/the-second-developer-preview-of-android-15.html for details. One could use that and fall back to the .. less good free libraries pre-11/pre-11-with-compat
m
Does the new PDF renderer allow input data from memory like a ByteArray or an InputStream? The lack of this is my main pain point with the current PdfRenderer.
j
On Android can you just open the PDF in a web view to render it? Depending on your use-case, that might be enough.
m
Not really. I have to render it into an image and need to have some control of how it is rendered. At the moment I just store my data in a temporary file and then pass the file descriptor of that to the Android PDF renderer. This works but somehow looks stupid. I wonder why this
Copy code
val pfd = ParcelFileDescriptor.fromData(pdfBytes, "PDF")
is deprecated and hidden? It would be the perfect fit here.
f
If you try to render a large size approx to 100mb pdf on web view it will fail
👍 2
j
If it were me, I'd write a wrapper around PSPDFKit or the platform native libraries. It seems like a hard enough problem that I'd rather use a battle-tested solution rather than building something from the ground up. This is what I did with
AppAuth
and others have done with
CouchbaseLite
.
m
@Jacob Rhoda exactly what i mean
I‘d rather pay for a very good PDF lib on both platforms than to have a half-baked free lib. Had last year a project where we ended up implementing a webview with Adobe‘s PDF sdk, due to the lack of a solid free embedded Android PDF viewer. Would next time for sure choose PSPDFKIT