Coder Social home page Coder Social logo

pdfviewer's Introduction

Local PDF Viewer Library for Android

Overview

This Android library provides a lightweight and easy-to-use PDF viewer for local and online PDF files within your Android applications. Whether you want to include a PDF viewer in your app for reading documents or displaying user manuals, this library simplifies the integration process.

Key features:

  • View local PDF files.
  • View online PDF files.
  • Smooth and intuitive user interface.
  • Pinch to zoom

Screenshot

Installation

settings.gradle:

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

To get started, add the library to your Android project by including it as a dependency. You can do this by adding the following lines to your app's build.gradle file:

gradle

dependencies {
    implementation 'com.github.rishujam:PdfViewer:1.5'
}

How to use

XML File

    <com.docs.docwatcher.DocView
		android:id="@+id/docView"
		android:layout_width="match_parent"
		android:layout_height="match_parent"/>

Fragment/Activity

    companion object {
        private const val PATH = "/data/data/com.docs.pdfviewer/files/sample_pdf.pdf"
	private const val INTERNET_PATH =
            "https://research.nhm.org/pdfs/10840/10840-001.pdf"
    }

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        binding = ActivityMainBinding.inflate(layoutInflater)
        setContentView(binding.root)

	//If the path specified is a url you must set fromInternet value to true else set it to false.

        binding.docView.loadData(
            uri = INTERNET_PATH, 
            fromInternet = true,
        ) 

	// If you are loading pdf from url you can easily track progress using this function

	binding.docView.setDownloadStateChangeListener {
            when (it) {
                is DownloadState.Error -> {
                    Toast.makeText(this, it.message, Toast.LENGTH_SHORT).show()
                }

                is DownloadState.Completed -> {
                    //Do something..
                }

                is DownloadState.InProgress -> {
                    val totalFileSizeInBytes = it.totalSize
                    val progress = it.progress
                }
            }
        }
    }

pdfviewer's People

Contributors

rishujam avatar

Stargazers

 avatar gitzjy avatar Aditya Chandak avatar  avatar

Watchers

 avatar

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