# compose


10/03/2023, 4:47 AM
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'm not sure if i should do like
rememberPdfState(url: String)
rememberPdfState(file: File)
I would really like to make this happen (I have never made a library before) but it's difficult and i need advice


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.
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

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.

Albert Chang

10/03/2023, 1:19 PM
You can create a
interface and provide platform-specific implementations of it.
in compose is an example of this.
👍 1