Git Product home page Git Product logo

pdfy's Introduction

Pdfy

Simple, lightweight, PDF viewer for android. Supports assets paths, or internet URLs.

What does it do?

It will load a PDF and show it in a custom view, it can be scrolled vertically and zoomed in or out.

How can you open a PDF?

For now it only supports PDFs from assets or from a URL (using okhttp to download)

How does it work?

  • using PDFRenderer API from android
  • download the pdf file and store it in local cache as PDF, and load pages while they are viewed
  • show a recyclerview with all those images
  • let the images zoom in and out using Zoomage

How to use the library

Add it in your root build.gradle at the end of repositories:

allprojects {
    repositories {
        ...
        maven { url 'https://jitpack.io' }
    }
}

Add the dependency

dependencies {
    implementation 'com.github.boldijar:pdfy:<latest-version>'
}

Let the library know how to load the images. I didn't wanted to include this in the library because people might want to use their own caching library, you can chech the demo to see how to do this with Glide.

class GlideLoader : PdfyImageLoader() {
    override fun loadImage(path: String, imageView: ImageView) {
        Glide.with(imageView).load(path).into(imageView)
    }
}

And set the loader before you use the library:

PdfyParser.init(GlideLoader())

Now load a PDF:

pdfyView.setPdf(
    path = "http://www.ignaciouriarte.com/works/18/pdfs/A100page47.pdf",
    type = PdfyType.FROM_INTERNET,
    uniqueCacheName = "<somePdfId>" // optional, used for caching, default is a random UUID
)

You can also load it from assets, by using PdfyType.FROM_ASSETS and using the relative path after assets, or just use the LOCAL_FILE type, and use the absolute file path.

pdfy's People

Contributors

boldijar avatar

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.