Coder Social home page Coder Social logo

magicalpdfeditor's Introduction

API

MagicalPdfEditor

This is a small PDF editor based on OpenPDF Core and AndroidPdfViewer. As there is not much open source easy working PDF editors and PDF wizards, I decied to create a simple directory to resolve my issues. Here I have worked on two seprate cores, add some functionality into them and combining them together to acheive my target. I am working on this repo, any help will be appreciated.

Features

  • All functinality in AndroidPdfViewer (Load, Read, Render, Show, ... PDF Files)
  • Add annotations into pdf file
  • Add Image into pdf file as OCG item
  • Remove annotations from pdf file
  • Update annotation in pdf file
  • Save changes on same pdf file
  • Add observer pattern for better UX (prevent freez)
  • Draw line stream over pdf
  • Highlight text in pdf
  • Remove page from pdf file
  • Convert image to pdf with scale and zoom support
  • You can add transparent items into PDF pages
  • Maybe some other features ๐Ÿ˜œ

Usage

Just clone the project and trance the source code, It's realy easy and clear. Here an example how to use this lib.

Step 1. Add the JitPack repository to your build file, Add it in your root build.gradle at the end of repositories:

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

Step 2. Add the dependency

dependencies {
    implementation 'com.github.HamidrezaAmz:MagicalPdfEditor:LAST_VERSION'
}

Step 3. Add PDFViewer into your xml

<ir.vasl.magicalpec.view.MagicalPdfViewer
            android:id="@+id/magicalPdfViewer"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:background="#009688" />

For more examples and sample code please check this class from sample app.

Interfaces

Here is the list of interfaces that can help you work with this lib.

Interface Description
OnPageErrorListener Triggered when sth went wrong on loading the pdf file
OnLoadCompleteListener Triggered when loading pdf file finished
OnPageChangeListener Triggered when page status changed, this will give you page count an new page index
OnLongPressListener Triggered when user hold his/her finger on part of pdf screen, this will give you MotionEvent object
OnTapListener Triggered when user on tap on PDF screen, this will give you MotionEvent object
LinkHandler Triggered when user clicked on added annotation with link, this will give you LinkTapEvent you can extract stored data

Attention

Working with files is restricted in higher android api levels, So if you are working with high level android APIs, be aware of using file provides and needed permissions to work with files, Or you can use SimpleStorage lib to work with files and Android storage.

magicalpdfeditor's People

Contributors

hamidrezaamz avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

magicalpdfeditor's Issues

Error when editing Document

Permission Denial: writing com.android.providers.downloads.DownloadStorageProvider uri content://com.android.providers.downloads.documents/document/raw%3A%2Fstorage%2Femulated%2F0%2FDownload%2F130%204t.pdf from pid=5340, uid=10113 requires android.permission.MANAGE_DOCUMENTS, or grantUriPermission()

To avoid this I had To modify the code when opening a PDF like this

  Intent intent = new Intent(Intent.ACTION_OPEN_DOCUMENT);
        intent.addCategory(Intent.CATEGORY_OPENABLE);
        intent.setType("application/pdf");

How to support different document sizes?

After clicking to update an annotation, it is moved. I think this is related to the height and width of the document. What sizes are currently supported and what would you suggest to support different sizes? It would be nice if we can perform the calculations based on the opened document's sizes and not to assume the documents sizes. The different pages may have different sizes also.

Screen.Recording.2023-08-28.at.12.07.18.mov

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.