GithubHelp home page GithubHelp logo

arcanegolem / lycoris Goto Github PK

View Code? Open in Web Editor NEW
11.0 2.0 1.0 16.9 MB

Simple and easy to use Android PDF Viewer library. Made with and for Jetpack Compose. PDFs from Raw Resources, URIs and URLs are supported.

License: Apache License 2.0

Kotlin 100.00%
jetpack-compose pdf-viewer pdf pdf-reader pdf-renderer compose-pdf lycoris pdf-document ready-to-use

lycoris's Introduction

Lycoris

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

Contents

DEMO

This can be achieved with following code (Sample in MainActivity):

// ...
Column (
  modifier = Modifier.fillMaxSize()
) {
  PdfViewer (
    pdfResId = R.raw.sample_multipage,
    controlsAlignment = Alignment.CenterEnd,
  )
}
// ...

NEW(!)

PdfViewer

  • Now has zoom controls instead of separate dialogs for each page
  • Added iconTint and accentColor for zoom controls (NOTE: accentColor will apply with 40% alpha)
  • Added controlsAlignment parameter for zoom controls positioning inside PdfViewer's box
  • Added bitmapScale for upscaling/downscaling pages for better readability/performance
  • Added support for documents with unordinary aspect ratios

HorizontalPagerPdfViewer

  • Now marked Experimental
  • Is unstable and unmaintained for now

VerticalPagerPdfViewer

  • Now marked Experimental
  • Is unstable and unmaintained for now

Requirements

  • Add INTERNET permission 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 unsecure http:// 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'
}

Usage

Module contains overloaded PdfViewer, HorizontalPagerPdfViewer and VerticalPagerPdfViewer ready-to-use composable functions, usage examples below:

WARNING: PdfViewer function utilizes LazyColumn composable.

PDF from Raw Resource

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
)

PDF from Uri

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
)

PDF from URL

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

Thanks to

Known issues

lycoris's People

Contributors

arcanegolem avatar mklkj avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

mklkj

lycoris's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.