All Projects → voghDev → Pdfviewpager

voghDev / Pdfviewpager

Licence: apache-2.0
Android widget that can render PDF documents stored on SD card, linked as assets, or downloaded from a remote URL.

Programming Languages

java
68154 projects - #9 most used programming language

Projects that are alternatives of or similar to Pdfviewpager

Pdf Lib
Create and modify PDF documents in any JavaScript environment
Stars: ✭ 3,426 (+127.19%)
Mutual labels:  library, pdf, pdf-document
Printable Mockups
Create printable UI mockups & wireframes templates
Stars: ✭ 479 (-68.24%)
Mutual labels:  pdf, pdf-document
Tabulizer
Bindings for Tabula PDF Table Extractor Library
Stars: ✭ 413 (-72.61%)
Mutual labels:  pdf, pdf-document
Itext7
iText 7 for Java represents the next level of SDKs for developers that want to take advantage of the benefits PDF can bring. Equipped with a better document engine, high and low-level programming capabilities and the ability to create, edit and enhance PDF documents, iText 7 can be a boon to nearly every workflow.
Stars: ✭ 913 (-39.46%)
Mutual labels:  library, pdf
Technical Ebooks
PDFs for programming tutorials.
Stars: ✭ 342 (-77.32%)
Mutual labels:  pdf, pdf-document
Ptshowcaseviewcontroller
An initial implementation of a "showcase" view( controller) for iOS apps... Visualizes images, videos and PDF files beautifully! (by @pittleorg) [meta: image, photo, video, document, pdf, album, gallery, showcase, gallery, iOS, iPhone, iPad, component, library, viewer]
Stars: ✭ 395 (-73.81%)
Mutual labels:  library, pdf
Itext7 Dotnet
iText 7 for .NET is the .NET version of the iText 7 library, formerly known as iTextSharp, which it replaces. iText 7 represents the next level of SDKs for developers that want to take advantage of the benefits PDF can bring. Equipped with a better document engine, high and low-level programming capabilities and the ability to create, edit and enhance PDF documents, iText 7 can be a boon to nearly every workflow.
Stars: ✭ 698 (-53.71%)
Mutual labels:  library, pdf
Raz
Modern & multiplatform game engine in C++17
Stars: ✭ 161 (-89.32%)
Mutual labels:  rendering, library
Pdfio.jl
PDF Reader Library for Native Julia.
Stars: ✭ 56 (-96.29%)
Mutual labels:  pdf, pdf-document
Documentreader
This library reads word documents (.doc and .docx), txt and PDF files, and gives the output content of the document as a String.
Stars: ✭ 57 (-96.22%)
Mutual labels:  pdf, pdf-document
Vulkan2drenderer
Easy to use 2D rendering engine using Vulkan API as backend.
Stars: ✭ 60 (-96.02%)
Mutual labels:  rendering, library
Php Svg
Vector graphics (SVG) library for PHP
Stars: ✭ 256 (-83.02%)
Mutual labels:  rendering, library
Boxable
Boxable is a library that can be used to easily create tables in pdf documents.
Stars: ✭ 253 (-83.22%)
Mutual labels:  pdf, pdf-document
Pdfpig
Read and extract text and other content from PDFs in C# (port of PdfBox)
Stars: ✭ 391 (-74.07%)
Mutual labels:  pdf, pdf-document
Media Watermark
GPU/CPU-based iOS Watermark Library for Image and Video Overlay
Stars: ✭ 170 (-88.73%)
Mutual labels:  rendering, library
Ascii art
Real-Time ASCII Art Rendering Library
Stars: ✭ 599 (-60.28%)
Mutual labels:  rendering, library
D2dlib
A .NET library for hardware-accelerated, high performance, immediate mode rendering via Direct2D.
Stars: ✭ 84 (-94.43%)
Mutual labels:  rendering, library
Vrt
🔅 Ray tracing library for Vulkan API (indev)
Stars: ✭ 111 (-92.64%)
Mutual labels:  rendering, library
Svglib
Read SVG files and convert them to other formats.
Stars: ✭ 139 (-90.78%)
Mutual labels:  rendering, pdf
Werender
Simple, light-weight, Canvas library for 2D rendering
Stars: ✭ 13 (-99.14%)
Mutual labels:  rendering, library

PdfViewPager

Download Android Arsenal Build Status

Android widget to display PDF documents in your Activities or Fragments.

Important note: PDFViewPager uses PdfRenderer class, which works only on API 21 or higher. See Official doc for details.

If you are targeting pre-Lollipop devices, have a look at the legacy sample

Installation

Add this line in your app/build.gradle

implementation 'es.voghdev.pdfviewpager:library:1.1.2'

If you want to use the old android.support instead of androidx, add this dependency

implementation 'es.voghdev.pdfviewpager:library:1.0.6'

Usage

Use PDFViewPager class to load PDF files from assets or SD card

Screenshot Screenshot

1.- Copy your assets to cache directory if your PDF is located on assets directory

CopyAsset copyAsset = new CopyAssetThreadImpl(context, new Handler());
copyAsset.copy(asset, new File(getCacheDir(), "sample.pdf").getAbsolutePath());

2a.- Create your PDFViewPager passing your PDF file, located in assets (see sample)

pdfViewPager = new PDFViewPager(this, "sample.pdf");

2b.- Or directly, declare it on your XML layout

<es.voghdev.pdfviewpager.library.PDFViewPager
    android:id="@+id/pdfViewPager"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    app:assetFileName="sample.pdf"/>

It will automatically have zooming and panning capability

3.- Release adapter in onDestroy

@Override
protected void onDestroy() {
    super.onDestroy();

    ((PDFPagerAdapter) pdfViewPager.getAdapter()).close();
}

PDF's on SD card

1.- Create a PDFViewPager object, passing the file location in your SD card

PDFViewPager pdfViewPager = new PDFViewPager(context, getPdfPathOnSDCard());

protected String getPdfPathOnSDCard() {
    File f = new File(getExternalFilesDir("pdf"), "adobe.pdf");
    return f.getAbsolutePath();
}

2.- Don't forget to release the adapter in onDestroy

    @Override
    protected void onDestroy() {
        super.onDestroy();

        ((PDFPagerAdapter) pdfViewPager.getAdapter()).close();
    }

Remote PDF's from a URL

Screenshot

1.- Add INTERNET, READ_EXTERNAL_STORAGE and WRITE_EXTERNAL_STORAGE permissions on your AndroidManifest.xml

<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />

2.- Make your Activity or Fragment implement DownloadFile.Listener

public class RemotePDFActivity extends AppCompatActivity implements DownloadFile.Listener {

3.- Create a RemotePDFViewPager object

String url = "http://www.cals.uidaho.edu/edComm/curricula/CustRel_curriculum/content/sample.pdf";

RemotePDFViewPager remotePDFViewPager =
      new RemotePDFViewPager(context, url, this);

4.- Configure the corresponding callbacks and they will be called on each situation.

@Override
public void onSuccess(String url, String destinationPath) {
    // That's the positive case. PDF Download went fine

    adapter = new PDFPagerAdapter(this, "AdobeXMLFormsSamples.pdf");
    remotePDFViewPager.setAdapter(adapter);
    setContentView(remotePDFViewPager);
}

@Override
public void onFailure(Exception e) {
    // This will be called if download fails
}

@Override
public void onProgressUpdate(int progress, int total) {
    // You will get download progress here
    // Always on UI Thread so feel free to update your views here
}

5.- Don't forget to close adapter in onDestroy to release all resources

@Override
protected void onDestroy() {
    super.onDestroy();

    adapter.close();
}

Usage in Kotlin

As you might figure out, the library is fully usable in Kotlin programming language. You can find example code here.

Just import the library as a gradle dependency as you would do in Java.

TODOs

  • Make initial Pdf scale setable by code (requested by various users on issues)
  • Load PDF documents from SD card
  • Make PDF documents zoomable with pinch and double tap (two approaches, ImageViewZoom and photoview)
  • Unify all features in only one PDFViewPager and PDFPagerAdapter class
  • Support API Levels under 21, by downloading PDF and invoking system native intent.
  • UI tests
  • Add checkstyle, refactor & improve code quality

See changelog for details

Developed By

Follow me on Twitter Find me on Linkedin

Support

This repository has been supported by JetBrains with free licenses for all JetBrains products

License

Copyright 2016 Olmo Gallegos Hernández

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

   http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

Contributing

For noobs (like me some months ago)

fork the project into your GitHub account
now clone your GitHub repo for this project
implement your changes
commit your changes, push them into your repo
review your code and send me a pull request if you consider it

For not-so-noobs

Please make sure that your changes pass both checkstyle and UI tests before submitting them

./gradlew checkstyle

./gradlew test

And with your Android device connected

./gradlew connectedCheck
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].