How to get the copy and paste selection in MuPdf.
I want to get like this below image.
Let me start with my standard spiel...
MuPDF is, at heart, a portable C library for opening/manipulating/rendering PDF (and other) file formats. It provides a C level API. Provided with the MuPDF library are various tools (such as PDF manipulation/rendering utilities, and example viewers for various different platforms).
As far as possible all the 'smarts' for these tools are encapsulated within the core library, and the tools themselves are thin veneers over this core functionality.
The Android viewer is one such example of this. The UI is written in Java, and it calls down to the core using a set of JNI functions to do all the file opening/page selection/rendering etc.
Now onto your question:
The logic for text selection already exists within MuPDF. Open a PDF, then from the top bar select the rightmost icon "(v)" to see more options. Choose the "Copy to clipboard" option from here.
Then you can drag your finger across the area of text you want selected. It will be highlighted on screen. Then click the tick icon in the top bar to finalise.
You can then swap app and paste the text out again. (All this assumes that the PDF has been built in a reasonable way so we can figure out what unicode char each glyph on the page corresponds to).
What MuPDF doesn't offer are the selection 'end tags' that you can drag with your finger. If you want that, you'll need to alter the android viewer specific java classes yourself. You shouldn't need to make any changes within the MuPDF core to support what you want. You might possibly need to tweak the JNI classes a bit.
It's probably not a huge job for a competent Android app developer, but it's too large for us to provide detailed information on a Stack Overflow answer.
If you have more questions, please don't hesitate to come visit us in the #ghostscript irc channel on freenode (see www.mupdf.com for a web link you can use if you don't have an irc client set up).
Related
On my iPad, when i touch and hold a specific word in, for example, a PDF document, the word gets highlighted and I get three options, Copy, Search, Define. Choosing the Define option brings up the English definition of the highlighted word in what seems like a built-in dictionary. Is it possible to add this type of functionality to my app using a standard TextView without having to create an entire Dictionary database? Does Android already have one?
There's nothing like that built in. You may be able to find a third party library, but most likely you'd need to build your own from scratch.
I started with Android Studio and would like to get started.
I do not like fiddling around with GUIs and would like to play lego with ready-made pages and common standard interfaces.
Where can I find Android GUI XMLs to copy&paste or download to get started?
Does anyone know a good Android resource site, something like templatemonster for Android GUIs?
For example I need:
a settings page with switches, range sliders and a couple of fields, nicely arranged and already profesionallly looking
a user profile page
an inbox/outbox
a speech bubble view
list/grid view with images
a login/signup/lost password menu
You can use library for GUI and many other purpose the best place is Android assets studio
And there is a page that haves tricks for GUI is Android cheat sheet
And Android assets studio for images
If you get stuck visit Android's official site
Grabbed by JRummy's Blog
For my app I need (like I think many and many devs) to customise colours and drawables; at the moment I need to customise a platform drawable (the action bar background, which for the android platform is ab_solid_light(or _dark)_holo.9.png) which can be taken from various sources (android.jar, git, etc.). In my case, I'd like to modify it from grey to another color; can I simply take it, modify it with gimp/Photoshop/similar application and include in my resources? Should I give credits to aosp in "open source licenses" section of my app? Is there a standard or conventional way to do these kind of things?
What I mean to say while you're just getting started with the development and say you add a slider theres a predefined skin for that and you can place it somewhere on the screen, but in some apps there are things like a knob in a place of slider which you can rotate to do the same stuff what the slider does . How do they do that, does it require openGL or something I am not asking for a complete tutorial or something just curious on what stuff goes into building such thing
Mostly, if something is not provided out of the box, you will have to build your own control.
For example, you mention a Knob. That isn't available in the Android SDK. Such a control could prove to be useful.
Here is a tutorial to build such a custom Control: http://go-lambda.blogspot.in/2012/02/rotary-knob-widget-on-android.html
This is an image of the final result from the tutorial linked above:
Here is an example of a custom slider / seek bar: http://permadi.com/blog/2011/11/android-sdk-custom-slider-bar-seekbar/
This should give you a rough idea on how to go about creating your own custom views.
And finally, what I personally find the best possible resource for keeping track of almost all good Custom Views is here: http://www.androidviews.net/
The androidviews.net website has shut down. Android Arsenal is a new website that lists several third party Android libraries.
I have compiled MuPDF correctly and have been able to run the sample app without an issue, but:
Problem
I want to have a functionality like highlights,underlines, sticky notes, arrows, lines, ovals, rectangles, freehand drawings and text boxes on which user long pressed by his finger, as in RepliGo PDF Reader pdf reader and others.
I searched a lot, but didn't find any relevant way, link or hint to achieve the desired feature.
Can someone share any idea on how to achieve the aforementioned functionality?
It would be even more helpful if someone can explain it by sharing some code or example.
As MuPdf doesn't expose apis for the features you require, I suggest using the PDFTron sdk library for android.
As you can see on their docs page, it supports lot of annotation related pdf features:
Ready-to-Use Tools for Rapid Development - including support for
advanced features such as text selection, full text search; links;
bookmark navigation and manipulation; interactive forms; various
annotation capabilities to enable PDF markup (text highlight,
underline, strikeout, squiggly, line, rectangle, ellipse, arrow,
sticky note, and free-hand tool mode, etc.).
http://www.pdftron.com/pdfnet/mobile/android_pdf_library.html