PDFExpress is a Kotlin library designed to render PDF files efficiently in Android applications. It allows for downloading, rendering, and displaying PDFs with enhanced features like fixed page sizes, high-quality rendering, and support for remote URLs.
- Render PDFs from local files or remote URLs.
- High-quality bitmap rendering for pages.
- Fixed maximum page size for consistent layouts.
- Easy-to-use Composable integration with Jetpack Compose.
- Cache handling for optimized performance.
Add the following permissions to your AndroidManifest.xml:
<uses-permission android:name="android.permission.INTERNET" />@Composable
fun PDFScreen(fileUri: Uri, onBack: () -> Unit) {
Box(modifier = Modifier.fillMaxSize()) {
TextButton(onClick = onBack) {
Text("Back")
}
PDFReaderScreen(fileUri = fileUri, context = LocalContext.current, onBack = onBack)
}
}@Composable
fun PdfFromUrl(url: String, onBack: () -> Unit) {
Column(
modifier = Modifier.fillMaxSize(),
verticalArrangement = Arrangement.Center,
horizontalAlignment = Alignment.CenterHorizontally
) {
PDFReaderFromUrl(url = url, onBack = onBack)
}
}
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
mavenCentral()
maven { url 'https://jitpack.io' }
}
}
dependencies {
implementation 'com.github.realjoni17:PDFXpress:1.0.0'
}
- Ensure Network Permissions: Validate the
INTERNETpermission is added. - Test URLs: Check the provided URL in a browser to confirm accessibility.
- Log Errors: Use
Log.eto print exceptions during downloads or rendering.
This library is open-source and free to use under the MIT License. See the LICENSE file for details.