Lycoris is an effortless PDF viewing library which provides ready-to-use PDF viewing composables fully made with and for Jetpack Compose. Depends on Retrofit2, Coil and Material Icons. Supports PDF from Raw resources, Uri and URL.
This can be achieved with following code (Sample in MainActivity):
// ...
Column (
modifier = Modifier.fillMaxSize()
) {
PdfViewer (
pdfResId = R.raw.sample_multipage,
controlsAlignment = Alignment.CenterEnd,
)
}
// ...- Now has zoom controls instead of separate dialogs for each page
- Added
iconTintandaccentColorfor zoom controls (NOTE:accentColorwill apply with 40% alpha) - Added
controlsAlignmentparameter for zoom controls positioning inside PdfViewer's box - Added
bitmapScalefor upscaling/downscaling pages for better readability/performance - Added support for documents with unordinary aspect ratios
- Now marked Experimental
- Is unstable and unmaintained for now
- Now marked Experimental
- Is unstable and unmaintained for now
- Add
INTERNETpermission to your Android Manifest
<uses-permission android:name="android.permission.INTERNET" />- [OPTIONAL] Set
android:usesCleartextTraffic="true"in your Android Manifest<application>tag to enable downloading of PDF documents from unsecurehttp://URLs
<application>
...
android:usesCleartextTraffic="true"
...
</application>- Add Jitpack to your project repositories
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
mavenCentral()
maven { url 'https://jitpack.io' }
}
}- Add lycoris to your project dependencies
dependencies {
implementation 'com.github.arcanegolem:Lycoris:1.0.0-alpha01'
}Module contains overloaded PdfViewer, HorizontalPagerPdfViewer and VerticalPagerPdfViewer ready-to-use composable functions, usage examples below:
WARNING: PdfViewer function utilizes LazyColumn composable.
PdfViewer (
modifier: Modifier = Modifier,
@RawRes pdfResId: Int,
pagesVerticalArrangement: Arrangement.Vertical = Arrangement.spacedBy(8.dp),
iconTint : Color = Color.Black,
accentColor : Color = Color.DarkGray,
controlsAlignment: Alignment = Alignment.BottomEnd,
bitmapScale : Int = 1
)
VerticalPagerPdfViewer (
modifier: Modifier = Modifier,
@RawRes pdfResId: Int,
documentDescription : String
)
HorizontalPagerPdfViewer(
modifier: Modifier = Modifier,
@RawRes pdfResId: Int,
documentDescription : String
)PdfViewer (
modifier: Modifier = Modifier,
uri: Uri,
pagesVerticalArrangement: Arrangement.Vertical = Arrangement.spacedBy(8.dp),
accentColor: Color = Color.DarkGray,
iconTint: Color = Color.Black,
controlsAlignment: Alignment = Alignment.BottomEnd,
bitmapScale : Int = 1
)
VerticalPagerPdfViewer(
modifier: Modifier = Modifier,
uri: Uri
)
HorizontalPagerPdfViewer(
modifier: Modifier = Modifier,
uri: Uri
)PdfViewer(
modifier: Modifier = Modifier,
@Url url: String,
headers: HashMap<String, String>? = null,
pagesVerticalArrangement: Arrangement.Vertical = Arrangement.spacedBy(8.dp),
accentColor: Color = Color.DarkGray,
iconTint: Color = Color.Black,
controlsAlignment: Alignment = Alignment.BottomEnd,
bitmapScale : Int = 1
)
VerticalPagerPdfViewer(
modifier: Modifier = Modifier,
@Url url: String
headers: HashMap<String, String>,
)
HorizontalPagerPdfViewer(
modifier: Modifier = Modifier,
@Url url: String,
headers: HashMap<String, String>
)- Mikołaj Pich for preparing Lycoris for it's initial release.
