Im trying to make a compose multiplatform PDF viewer. I've never made like a full library before, so.. I'm having issues with getting all the code together, and making it multiplatform. Cause on android the PdfRenderer takes a ParcelFileDescriptor class. On desktop I'm using icepdf (not sure if theres better). I need to make like a state class, then various ways for a developer to provide the PDF: url or a file. So how would i represent that internally in my PdfState class? On android I first need to download to a temporary file, but not on desktop. I would really like to make this happen but it's difficult and i need advice
a
ascii
10/03/2023, 5:45 AM
This is barely about Compose, slightly about multiplatform, and mostly about just plain old programming.
Perhaps #getting-started would be a better place for the core question. Have a look at `expect`/`actual`; exposes signatures to users and your platform-specific code can be a black box.
ascii
10/03/2023, 5:48 AM
Strings are fine to start with. They're the most obvious common link to everything. For example, ParcelFD can be opened from a file, which of course can be accessed via a string path.
If web doesn't need permission grants or copies of data you can just skip all that stuff in web's
actual
.
m
Michael Paus
10/03/2023, 8:08 AM
Getting the APIs right is never easy. I, for example, need to read the PDFs from a ByteArray because I store the files as a BLOB in a database.
a
Albert Chang
10/03/2023, 1:19 PM
You can create a
PdfFile
interface and provide platform-specific implementations of it.